package com.mission.schedule.applcation;

import android.app.Application;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;
import com.baidu.mobads.sdk.api.BDAdConfig;
import com.baidu.mobads.sdk.api.BDDialogParams;
import com.baidu.mobads.sdk.api.MobadsPermissionSettings;
import com.baidu.mobads.sdk.api.NovelSDKConfig;
import com.bun.miitmdid.core.MdidSdkHelper;
import com.bun.miitmdid.interfaces.IIdentifierListener;
import com.bun.miitmdid.interfaces.IdSupplier;
import com.iflytek.cloud.SpeechUtility;
import com.mission.schedule.R;
import com.mission.schedule.activity.NewFriendsActivity;
import com.mission.schedule.ad.AdSettingHelper;
import com.mission.schedule.ad.AdSettingProperties;
import com.mission.schedule.add603.bean.UserNewLy;
import com.mission.schedule.bean.CalenderNoteBean;
import com.mission.schedule.bean.NoteLYBean;
import com.mission.schedule.bean.NoteTypeBean;
import com.mission.schedule.bean.RepeatBean;
import com.mission.schedule.bean.TagCommandBean;
import com.mission.schedule.bean.UserFrendsTask;
import com.mission.schedule.bean.UserFrendsTaskClass;
import com.mission.schedule.bean.WBA_FindFunctionMy;
import com.mission.schedule.bean.qd606.CLInventoryListBean;
import com.mission.schedule.bean.qd606.NoteTitleDetailBean;
import com.mission.schedule.bean.repeat607.RepeatRecommendContent;
import com.mission.schedule.bean.repeat607.RepeatRecommendTitle;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.db.DBHelper;
import com.mission.schedule.entity.CLAdsTable;
import com.mission.schedule.entity.CLCategoryTable;
import com.mission.schedule.entity.CLFindScheduleTable;
import com.mission.schedule.entity.CLNFMessage;
import com.mission.schedule.entity.CLRepeatTable;
import com.mission.schedule.entity.FMessages;
import com.mission.schedule.entity.FriendsTable;
import com.mission.schedule.entity.LocateAllMemoTable;
import com.mission.schedule.entity.LocateAllNoticeTable;
import com.mission.schedule.entity.LocateOldAllNoticeTable;
import com.mission.schedule.entity.LocateRepeatNoticeTable;
import com.mission.schedule.entity.LocateSolarToLunar;
import com.mission.schedule.entity.ScheduleTable;
import com.mission.schedule.my160920.FrendBean;
import com.mission.schedule.my160920.bean.CommonReplyBean;
import com.mission.schedule.my160920.bean.FrendLyBean;
import com.mission.schedule.my160920.bean.FriendBean;
import com.mission.schedule.my160920.bean.FriendBeanTable;
import com.mission.schedule.my160920.bean.FriendDownAllScheduleBean;
import com.mission.schedule.my160920.bean.FriendDownAllScheduleTable;
import com.mission.schedule.utils.CalendarChangeValue;
import com.mission.schedule.utils.CharacterUtil;
import com.mission.schedule.utils.DateTimeHelper;
import com.mission.schedule.utils.DateUtil;
import com.mission.schedule.utils.RepeatDateUtils;
import com.mission.schedule.utils.SharedPrefUtil;
import com.mission.schedule.utils.StringUtils;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;

public class App extends Application implements Thread.UncaughtExceptionHandler {//
    private static App mContextApplication = null;
    private DBHelper helper = null;
    private SharedPrefUtil sp;
    public static int repschId;
    public static int schID;
    public static int nfmId;
    public static int fstRepeatId;
    public static RequestQueue queues;

    public static App get(Context context) {
        return (App) context.getApplicationContext();
    }

    public float pointX, pointY, rawX, rawY, viewH, viewW;
    public View pointV;

    @Override
    public void onCreate() {
        super.onCreate();
//        Log.e("TAG","app_start1");
        mContextApplication = this;
        queues = Volley.newRequestQueue(getApplicationContext());
        sp = new SharedPrefUtil(mContextApplication, ShareFile.USERFILE);
        initDBHelper(this);
        initImageLoader(getApplicationContext());

        JPushInterface.init(this); // 初始化 JPush
//		CrashReport.initCrashReport(getApplicationContext(), "900033407", false);
//        String pushAlias = sp.getString(mContextApplication, ShareFile.USERFILE, ShareFile.PUSH_ALIAS, "0");// 第一次
//        if ("0".equals(pushAlias)) {
//            // 调用JPush API设置Alias
//            String udid = JPushInterface.getRegistrationID(getApplicationContext());
//            JPushInterface.setAliasAndTags(getApplicationContext(),udid, null, null);
//            sp.putString(mContextApplication, ShareFile.USERFILE, ShareFile.PUSH_ALIAS, "1");
//        }
        // JPushInterface.setDebugMode(false); // 设置开启日志,发布时请关闭日志

        // 应用程序入口处调用，避免手机内存过小，杀死后台进程后通过历史intent进入Activity造成SpeechUtility对象为null
        // 如在Application中调用初始化，需要在Mainifest中注册该Applicaiton
        // 注意：此接口在非主进程调用会返回null对象，如需在非主进程使用语音功能，请增加参数：SpeechConstant.FORCE_LOGIN+"=true"
        // 参数间使用半角“,”分隔。
        // 设置你申请的应用appid,请勿在'='与appid之间添加空格及空转义符

        // 注意： appid 必须和下载的SDK保持一致，否则会出现10407错误

        SpeechUtility.createUtility(getApplicationContext(), "appid=" + getString(R.string.app_id));

        // 以下语句用于设置日志开关（默认开启），设置成false时关闭语音云SDK日志打印
        // Setting.setShowLog(false);
//        Log.e("TAG","app_start2");

        initBDAd();
    }

    public static RequestQueue getHttpQueues() {
        return queues;
    }

    private void initDBHelper(Context context) {
        if (helper == null) {
            helper = new DBHelper(context);
        }
    }

    public static App getDBcApplication() {
        return mContextApplication;
    }

    private void initBDAd() {
        //获取SDK版本号，可调用方法：AdSettings.getSDKVersion();
        //弹窗样式类型	对应值	弹窗按钮动效类型	对应值
        //底部呼起	BDDialogParams.TYPE_BOTTOM_POPUP	无动效	BDDialogParams.ANIM_STYLE_NONE
        //居中普通	BDDialogParams.TYPE_BOTTOM_NORMAL	呼吸	BDDialogParams.ANIM_STYLE_BREATHE
        //居中点缀	BDDialogParams.TYPE_BOTTOM_DECORATE	扫光	BDDialogParams.ANIM_STYLE_SWIPE
        //手指引导	BDDialogParams.ANIM_STYLE_GUIDE
        //集成信通院MSA http://msa-alliance.cn/
        try {
            // 初始化MSA SDK
            // JLibrary.InitEntry(this);
            //获取OAID
            int sdkState = MdidSdkHelper.InitSdk(getApplicationContext(), true, new IIdentifierListener() {
                @Override
                public void OnSupport(boolean b, IdSupplier idSupplier) {
                    if (idSupplier != null) {
                        String oaid = idSupplier.getOAID();
                        Log.e("oaid", "oaid=" + oaid);
                    }
                }
            });
            Log.e("mdidsdk", "初始化" + sdkState);
        } catch (Throwable tr) {
            tr.printStackTrace();
        }

        BDAdConfig bdAdConfig = new BDAdConfig.Builder()
                // 1、设置app名称，可选
                .setAppName(getString(R.string.app_name))
                // 2、应用在mssp平台申请到的appsid，和包名一一对应，此处设置等同于在AndroidManifest.xml里面设置
                .setAppsid("f982f1bc")
                // 3、设置下载弹窗的类型和按钮动效样式，可选
                .setDialogParams(new BDDialogParams.Builder()
                        .setDlDialogType(BDDialogParams.TYPE_BOTTOM_POPUP)
                        .setDlDialogAnimStyle(BDDialogParams.ANIM_STYLE_NONE)
                        .build())
                .build(this);
        bdAdConfig.init();

        // 设置SDK可以使用的权限，包含：设备信息、定位、存储、APP LIST
        // 注意：建议授权SDK读取设备信息，SDK会在应用获得系统权限后自行获取IMEI等设备信息
        // 授权SDK获取设备信息会有助于提升ECPM
        //设置SDK获取设备信息权限（建议）
        MobadsPermissionSettings.setPermissionReadDeviceID(AdSettingHelper.getInstance()
                .getBooleanFromSetting(AdSettingProperties.COMMON_PERMISSION_PHONE_STATE, true));
        //设置SDK获取应用列表权限（建议）
        MobadsPermissionSettings.setPermissionAppList(AdSettingHelper.getInstance()
                .getBooleanFromSetting(AdSettingProperties.COMMON_PERMISSION_APP_LIST, true));
        //设置SDK获取粗略定位权限
        MobadsPermissionSettings.setPermissionLocation(AdSettingHelper.getInstance()
                .getBooleanFromSetting(AdSettingProperties.COMMON_PERMISSION_LOCATION, false));
        //设置SDK获取外部存储权限
        MobadsPermissionSettings.setPermissionStorage(AdSettingHelper.getInstance()
                .getBooleanFromSetting(AdSettingProperties.COMMON_PERMISSION_STORAGE, false));
        // 媒体需要小说产品的情况下，需要调用该方法进行初始化，该Appsid不需要与实例化BDAdConfig使用同一个appsid。
        // 我们推荐但不强制媒体在Application中调用该方法，媒体保证在使用小说产品之前该方法能够得到执行即可。
//        NovelSDKConfig.attachBaseContext(MobadsApplication.getContext(), "Your AppSid", "Your App Name");
    }

    private List<Map<String, String>> mChooseList;

    public List<Map<String, String>> getmChooseList() {
        return mChooseList;
    }

    public void setmChooseList(List<Map<String, String>> mChooseList) {
        this.mChooseList = mChooseList;
    }


    /**
     * 查询我的时间表列表集合
     *
     * @param timeType -1上传新建日程，updatestate不为0的都上传
     *                 0 待办 今天以前+全天+未结束+自动顺延 隐藏未结束的待办 1待办 今天以前+全天+未结束+自动顺延 显示未结束的待办
     *                 显示未结束的待办 2今天 + 不顺延 + 显示时间+未结束3 明天 4一周以内 5一周以外 7 今天 + 不顺延 + 显示时间+所有
     *                 8以前,9今后  10  两天以前+未结束+未读 11 昨天+未结束+未读12今天+未结束+未读 13明天+未结束+未读 14一周以内+未结束+未读
     *                 15一周以后+未结束+未读 16全部+未结束+未读 17 昨天+未结束 18 昨天以前+未结束 19 查询以前顺延状态，并且未结束
     *                 20  查询SChAID相同的日程 21 日程分享webview 22 昨天+全部  23 昨天以前+全部
     *                 24 全部+重要 25 两天以前+重要 26 昨天+重要 27今天+重要 28 明天+重要 29一周以内+重要 30一周以后+重要
     *                 31 两天以前+重要+未结束 32 昨天+重要+未结束 33今天+重要+未结束  34明天+重要+未结束  35一周以内+重要+未结束 36一周以后+重要+未结束
     *                 37 全部+来自好友 38 两天以前+来自好友 39 昨天+来自好友 40今天+来自好友 41明天+来自好友 42一周以内+来自好友 43一周以后+来自好友
     *                 44两天以前+来自好友+未结束 45 昨天+来自好友+未结束 46今天+来自好友+未结束 47明天+来自好友+未结束 48一周以内+来自好友+未结束49一周以后+来自好友+未结束
     *                 50 两天以前+分类 51 昨天+分类 52今天+分类 53明天+分类 54一周以内+分类 55一周以后+分类
     *                 56 两天以前+分类+未结束 57 昨天+分类+未结束 58今天+分类+未结束 59明天+分类+未结束 60一周以内+分类+未结束 61一周以后+分类+未结束
     */

    public ArrayList<Map<String, String>> queryAllSchData(int timeType, int schAID, int colortype)
            throws Exception {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        ArrayList<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "";
        String yestoday;// 昨天
        String today;// 今天
        String tomorrow;// 明天
        String inweek;// 一周以内
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        yestoday = DateUtil.formatDate(calendar.getTime());
        calendar.setTime(new Date());
        today = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 1);
        tomorrow = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 7);
        inweek = DateUtil.formatDate(calendar.getTime());

        switch (timeType) {
            case -10://清单日程 未删除 未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schSourceDesc + " != '' and "
                        + ScheduleTable.schUpdateState
                        + " != 3 and " + ScheduleTable.schRead + " != 1  and (schRemark4 = '' or schRemark4 is NULL or schRemark4 = '0' or schRemark4 = '1' or schRemark4 = '1') and schIsEnd != 1 and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case -5://上传日程中删除的数据
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schUpdateState + " = " + 3
                        + " order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case -4://查询数据库中所有日程数据
                sql = "select * from " + ScheduleTable.ScheduleTable + " order by schDate asc, schTime asc";
                break;
            case -3:// 待办 今天+不显示时间+顺延   闹钟相关
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        //+ ScheduleTable.schRepeatID + " = " + 0 + " and "
                        + ScheduleTable.schDisplayTime + " = " + 0 + " and "
                        + ScheduleTable.schIsPostpone + " = " + 1
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case -2://闹钟相关
                updateshunyan();
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + today + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and  (("
                        //+ ScheduleTable.schRepeatID + " = " + 0 + " and "
                        + ScheduleTable.schDisplayTime + " = " + 1 + " and "
                        + ScheduleTable.schIsPostpone + " = " + 0 + ") or ("
                        + ScheduleTable.schDisplayTime + " = " + 0 + " and "
                        + ScheduleTable.schIsPostpone + " = " + 0
                        + ")  or (" + ScheduleTable.schDisplayTime + " = " + 1 + " and "
                        + ScheduleTable.schIsPostpone + " = " + 1
                        + "))   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case -1://上传新建日程，updatestate不为0和-1的都上传
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schUpdateState + " != " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + -1 + " and "
                        + ScheduleTable.schRepeatLink + " != " + 1 + " and "
                        + ScheduleTable.schRepeatLink + " != " + 3
                        + "   order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case -6:
                //全部代办
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 90:
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate = '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schIsEnd
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schCreateTime desc";//,schDisplayTime asc
                break;
            case 91:
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate = '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schIsEnd
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + " and "
                        + ScheduleTable.schID
                        + " > "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schTime desc";//,schDisplayTime asc
                break;
            case 0:// 待办 今天以前+全天+未结束+自动顺延 隐藏结束的待办 1结束
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate >= '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schIsEnd
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schID desc";//,schDisplayTime asc
                break;
            case 92:
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate = '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schCreateTime desc";
                break;
            case 93:// 待办 今天以前+全天+未结束+自动顺延 显示结束的待办
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate = '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + " and "
                        + ScheduleTable.schID
                        + " > "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schTime desc";//schDisplayTime asc,schCreateTime desc
                break;
            case 1:// 待办 今天以前+全天+未结束+自动顺延 显示结束的待办
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate = '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schID desc";//schDisplayTime asc,schCreateTime desc
                break;
            case 901:// 待办 今天以前+全天+未结束+自动顺延 显示结束的待办
                updatedaiban();
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate = '"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schIsEnd desc, schCreateTime desc";//schDisplayTime asc,schCreateTime desc
                break;
            case 2:// 今天 + 不顺延 + 显示时间 + 未结束
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate ='"
                        + today
                        + "' and "
                        + ScheduleTable.schIsEnd
                        + " != "
                        + 1
                        + " and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and ("
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 0
                        + " or "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 1
                        + ")   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";
                break;
            case 3:// 明天
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate ='"
                        + tomorrow
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";
                break;
            case 4:// 一周以内
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate <'"
                        + inweek
                        + "' and "
                        + " schDate >'"
                        + tomorrow
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";
                break;
            case 5:// 一周以外
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate >='"
                        + inweek
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";
                break;
            case 6:
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + "schDate =='" + DateUtil.formatDate(new Date())
                        + "' and " + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc ";
                break;
            case 7:// 今天 + 不顺延 + 显示时间 + 所有
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate ='"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and ("
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 0
                        + " or "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 1
                        + ")   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";
                break;
            case 907:// 今天 + 不顺延 + 显示时间 + 所有
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate ='"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and ("
                        + ScheduleTable.schDisplayTime
                        + " != "
                        + 0
                        + " or "
                        + ScheduleTable.schIsPostpone
                        + " != "
                        + 1
                        + ")   and schRemark3 is not '1' and schColorType < 999999 order by schIsEnd asc,schDisplayTime asc,schTime asc";
                break;
            case 8:// 8以前
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + "schDate<'" + DateUtil.formatDate(new Date()) + "'and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc ";
                break;

            case 9:// 今后DateUtil.formatDate(new Date())
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + "schDate>'"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc ";
                break;
            case 10:// 两天以前+未结束+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 11:// 昨天+未结束+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday
                        + "' and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 12:// 今天+未结束+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 13:// 明天+未结束+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 14:// 一周以内+未结束+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 15:// 一周以后+未结束+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 16://大于今天的全部+未读
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schRead + " = " + 1 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schID asc";//,schDisplayTime asc,schTime asc
                break;
            case 17:// 昨天+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday + "' and "
                        + ScheduleTable.schIsPostpone + " != 1 and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 18:// 昨天以前+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday + "' and "
                        + ScheduleTable.schIsPostpone + " != 1 and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 19://查询以前顺延状态，并且未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schDate + " < '" + today + "' and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and ("
                        + ScheduleTable.schRepeatID + " = " + 0 + " or ("
                        + ScheduleTable.schRepeatID + " != " + 0 + " and "
                        + ScheduleTable.schRepeatLink + " != " + 1
                        + "))   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 20:// 查询SChAID相同的日程
                sql = "select * from " + ScheduleTable.ScheduleTable
                        + " where " + ScheduleTable.schAID + " = " + schAID
                        + " and " + ScheduleTable.schAID + " > " + 0;
                break;
            case 21:// 日程分享webview
                sql = "select * from "
                        + ScheduleTable.ScheduleTable
                        + " where "
                        + " schDate >='"
                        + today
                        + "' and "
                        + ScheduleTable.schUpdateState
                        + " != "
                        + 3
                        + " and "
                        + ScheduleTable.schOpenState
                        + " = "
                        + 1
                        + " and "
                        + ScheduleTable.schIsEnd
                        + " = "
                        + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc";
                break;
            case 22:// 昨天+全部
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schDate + " = '" + yestoday + "' and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime desc,schTime desc";
                break;
            case 23:// 昨天以前+全部
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schDate + " < '" + yestoday + "' and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime desc,schTime desc";
                break;
            case 24://重要全部
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 25:// 两天以前+重要
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 26:// 昨天+重要
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 27:// 今天+重要
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 28:// 明天+重要
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 29:// 一周以内+重要
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 30:// 一周以后+重要
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 31:// 两天以前+重要+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 32:// 昨天+重要+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 33:// 今天+重要+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 34:// 明天+重要+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 35:// 一周以内+重要+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 36:// 一周以后+重要+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schIsImportant + " = " + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 37://全部+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 38:// 两天以前+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 39:// 昨天+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 40:// 今天+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 41:// 明天+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 42:// 一周以内+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 43:// 一周以后+来自好友
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 44:// 两天以前+来自好友+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 45:// 昨天+来自好友+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 46:// 今天+来自好友+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 47:// 明天+来自好友+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 48:// 一周以内+来自好友+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 49:// 一周以后+来自好友+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " > " + 0 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 50:// 两天以前+分类
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 51:// 昨天+分类
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 52:// 今天+分类
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 53:// 明天+分类
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 54:// 一周以内+分类
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 55:// 一周以后+分类
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 56:// 两天以前+分类+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 57:// 昨天+分类+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schIsEnd + " = " + 0 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 58:// 今天+分类+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today + "' and " + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 59:// 明天+分类+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow + "' and " + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 60:// 一周以内+分类+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek + "' and " + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 61:// 一周以后+分类+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schColorType + " = " + colortype + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek + "' and " + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 62:
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " < 0 and "
                        + ScheduleTable.schIsEnd + " != 1 and " + ScheduleTable.schUpdateState + " != 3 and "
                        + ScheduleTable.schDate + " >= '" + today + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 63:
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " < 0 and " + ScheduleTable.schUpdateState + " != 3 "
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 64:
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " < 0 and " + ScheduleTable.schUpdateState + " != 3 and "
                        + ScheduleTable.schDate + " >= '" + today + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 65://到期日全部
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 66:// 两天以前+到期日
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 67:// 昨天+到期日
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 68:// 今天+到期日
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 69:// 明天+到期日
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 70:// 一周以内+到期日
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 71:// 一周以后+到期日
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 72:// 两天以前+到期日+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " < '" + yestoday + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 73:// 昨天+到期日+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + yestoday + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 74:// 今天+到期日+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + today + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 75:// 明天+到期日+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " = '" + tomorrow + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "   and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 76:// 一周以内+到期日+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " > '" + tomorrow + "' and "
                        + ScheduleTable.schDate + " < '" + inweek + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "  and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            case 77:// 一周以后+到期日+未结束
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schcRecommendId + " = -" + 1 + " and "
                        + ScheduleTable.schUpdateState + " != " + 3 + " and "
                        + ScheduleTable.schDate + " >= '" + inweek + "' and "
                        + ScheduleTable.schIsEnd + " = " + 0
                        + "  and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
                break;
            default:
                if (colortype == 0) {
                    sql = "select * from "
                            + ScheduleTable.ScheduleTable
                            + " where (schRemark4 = '' or schRemark4 is NULL or schRemark4 = '0' or schRemark4 = '1') and schRemark3 is not '1' and schColorType = " + timeType + " order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";

                } else {
                    sql = "select * from "
                            + ScheduleTable.ScheduleTable
                            + " where "
                            + "schDate >='"
                            + today
                            + "'  and schRemark3 is not '1' and schColorType = " + timeType + " order by schDate asc,schDisplayTime asc,schTime asc,schCreateTime asc  ";

                }
                break;

        }
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.ID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.ID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                dataList.add(noticeMap);

            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }


        for (int i = 0; i < dataList.size() - 1; i++) {
            if (dataList.get(i).get(ScheduleTable.schRepeatLink).equals("1") || dataList.get(i).get(ScheduleTable.schRepeatLink).equals("3")) {
                Map<String, String> m1 = dataList.get(i);
                for (int j = dataList.size() - 1; j > i; j--) {
                    Map<String, String> m2 = dataList.get(j);
                    if (m1.get(ScheduleTable.schContent).equals(m2.get(ScheduleTable.schContent))
                            && m1.get(ScheduleTable.schCreateTime).equals(m2.get(ScheduleTable.schCreateTime))
                            && m1.get(ScheduleTable.schRepeatDate).equals(m2.get(ScheduleTable.schRepeatDate))
                            && m1.get(ScheduleTable.schDate).equals(m2.get(ScheduleTable.schDate))
                            && m1.get(ScheduleTable.schTime).equals(m2.get(ScheduleTable.schTime))
                            && m1.get(ScheduleTable.schDisplayTime).equals(m2.get(ScheduleTable.schDisplayTime))
                            && m1.get(ScheduleTable.schIsPostpone).equals(m2.get(ScheduleTable.schIsPostpone))) {
                        if (m1.get(ScheduleTable.schRepeatID).equals(m2.get(ScheduleTable.schRepeatID)) || m2.get(ScheduleTable.schRepeatID).equals("-1")) {
                            deleteScheduleData(m2.get(ScheduleTable.schID));
                            dataList.remove(j);
                        }
                    }
                }
            }
        }


        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if ((m1.get(ScheduleTable.schSourceType).equals("3") && m2.get(ScheduleTable.schSourceType).equals("3")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("4") && m2.get(ScheduleTable.schSourceType).equals("4")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("5") && m2.get(ScheduleTable.schSourceType).equals("5"))) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc))) {
                        dataList.remove(j);
                        continue;
                    }
                }

                if (m1.get(ScheduleTable.schSourceType).equals("2") && m2.get(ScheduleTable.schSourceType).equals("2")) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc)) && !m1.get(ScheduleTable.schcRecommendName).isEmpty()) {
                        dataList.remove(j - 1);
                        continue;
                    }
                }
            }
        }

        return dataList;
    }

    public ArrayList<Map<String, String>> queryCalenderData(String date, int d) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        ArrayList<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap;
        String sql;
        if (d == 0) {
            // " + ScheduleTable.schDate + " = '" + date + "' and
            sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schIsEnd
                    + " != "
                    + 1
                    + " and "
                    + ScheduleTable.schUpdateState
                    + " != "
                    + 3 + " and (schDisplayTime != 0 or schIsPostpone != 1)  and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
        } else if (d == 1) {
            // " + ScheduleTable.schDate + " = '" + date + "'
            sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schIsEnd
                    + " != "
                    + 1
                    + " and "
                    + ScheduleTable.schUpdateState
                    + " != "
                    + 3
                    + " and "
                    + ScheduleTable.schDisplayTime
                    + " != "
                    + 1
                    + " and "
                    + ScheduleTable.schIsPostpone
                    + " != "
                    + 0 + "  and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
        } else if (d == 2) {
            sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schDate + " = '" + date + "' and "
                    + ScheduleTable.schUpdateState
                    + " != "
                    + 3 + " and (schDisplayTime != 0 or schIsPostpone != 1)  and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
        } else if (d == 3) {
            sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schDate + " = '" + date + "' and "
                    + ScheduleTable.schUpdateState
                    + " != "
                    + 3
                    + " and "
                    + ScheduleTable.schDisplayTime
                    + " != "
                    + 1
                    + " and "
                    + ScheduleTable.schIsPostpone
                    + " != "
                    + 0 + "  and schRemark3 is not '1' and schColorType < 999999 order by schDate asc,schDisplayTime asc,schTime asc";
        } else {
            sql = "select * from " + ScheduleTable.ScheduleTable + " where  schRemark3 is not '1' and schColorType = " + d + " order by schDate asc,schDisplayTime asc,schTime asc";
        }

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<>();
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.ID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.ID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                dataList.add(noticeMap);

            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        for (int i = 0; i < dataList.size() - 1; i++) {
            if (dataList.get(i).get(ScheduleTable.schRepeatLink).equals("1") || dataList.get(i).get(ScheduleTable.schRepeatLink).equals("3")) {
                Map<String, String> m1 = dataList.get(i);
                for (int j = dataList.size() - 1; j > i; j--) {
                    Map<String, String> m2 = dataList.get(j);
                    if (m1.get(ScheduleTable.schContent).equals(m2.get(ScheduleTable.schContent))
                            && m1.get(ScheduleTable.schCreateTime).equals(m2.get(ScheduleTable.schCreateTime))
                            && m1.get(ScheduleTable.schRepeatDate).equals(m2.get(ScheduleTable.schRepeatDate))
                            && m1.get(ScheduleTable.schDate).equals(m2.get(ScheduleTable.schDate))
                            && m1.get(ScheduleTable.schTime).equals(m2.get(ScheduleTable.schTime))
                            && m1.get(ScheduleTable.schDisplayTime).equals(m2.get(ScheduleTable.schDisplayTime))
                            && m1.get(ScheduleTable.schIsPostpone).equals(m2.get(ScheduleTable.schIsPostpone))) {
                        if (m1.get(ScheduleTable.schRepeatID).equals(m2.get(ScheduleTable.schRepeatID)) || m2.get(ScheduleTable.schRepeatID).equals("-1")) {
                            deleteScheduleData(m2.get(ScheduleTable.schID));
                            dataList.remove(j);
                        }
                    }
                }
            }
        }


        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if ((m1.get(ScheduleTable.schSourceType).equals("3") && m2.get(ScheduleTable.schSourceType).equals("3")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("4") && m2.get(ScheduleTable.schSourceType).equals("4")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("5") && m2.get(ScheduleTable.schSourceType).equals("5"))) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc))) {
                        dataList.remove(j);
                        continue;
                    }
                }

                if (m1.get(ScheduleTable.schSourceType).equals("2") && m2.get(ScheduleTable.schSourceType).equals("2")) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc)) && !m1.get(ScheduleTable.schcRecommendName).isEmpty()) {
                        dataList.remove(j - 1);
                        continue;
                    }
                }
            }
        }
        return dataList;
    }


    public ArrayList<Map<String, String>> queryCalenderData(String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        ArrayList<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap;
        String sql = "select * from "
                + ScheduleTable.ScheduleTable
                + " where "
                + "schDate = '"
                + date
                + "' and "
                + ScheduleTable.schUpdateState
                + " != "
                + 3 + " and schRemark3 is not '1' and schColorType < 999999 order by schIsEnd asc,schDisplayTime asc,schTime asc";

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<>();
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.ID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.ID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                dataList.add(noticeMap);

            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        for (int i = 0; i < dataList.size() - 1; i++) {
            if (dataList.get(i).get(ScheduleTable.schRepeatLink).equals("1") || dataList.get(i).get(ScheduleTable.schRepeatLink).equals("3")) {
                Map<String, String> m1 = dataList.get(i);
                for (int j = dataList.size() - 1; j > i; j--) {
                    Map<String, String> m2 = dataList.get(j);
                    if (m1.get(ScheduleTable.schContent).equals(m2.get(ScheduleTable.schContent))
                            && m1.get(ScheduleTable.schCreateTime).equals(m2.get(ScheduleTable.schCreateTime))
                            && m1.get(ScheduleTable.schRepeatDate).equals(m2.get(ScheduleTable.schRepeatDate))
                            && m1.get(ScheduleTable.schDate).equals(m2.get(ScheduleTable.schDate))
                            && m1.get(ScheduleTable.schTime).equals(m2.get(ScheduleTable.schTime))
                            && m1.get(ScheduleTable.schDisplayTime).equals(m2.get(ScheduleTable.schDisplayTime))
                            && m1.get(ScheduleTable.schIsPostpone).equals(m2.get(ScheduleTable.schIsPostpone))) {
                        if (m1.get(ScheduleTable.schRepeatID).equals(m2.get(ScheduleTable.schRepeatID)) || m2.get(ScheduleTable.schRepeatID).equals("-1")) {
                            deleteScheduleData(m2.get(ScheduleTable.schID));
                            dataList.remove(j);
                        }
                    }
                }
            }
        }


        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if ((m1.get(ScheduleTable.schSourceType).equals("3") && m2.get(ScheduleTable.schSourceType).equals("3")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("4") && m2.get(ScheduleTable.schSourceType).equals("4")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("5") && m2.get(ScheduleTable.schSourceType).equals("5"))) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc))) {
                        dataList.remove(j);
                        continue;
                    }
                }

                if (m1.get(ScheduleTable.schSourceType).equals("2") && m2.get(ScheduleTable.schSourceType).equals("2")) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc)) && !m1.get(ScheduleTable.schcRecommendName).isEmpty()) {
                        dataList.remove(j - 1);
                        continue;
                    }
                }
            }
        }
        return dataList;
    }

    public void deleteErrorRepeat() {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from ScheduleTable where schSourceDesc = '' and (schRepeatLink = 1 or schRepeatLink = 3)";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void getErrorRepeat() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select *  from ScheduleTable where schRepeatID != 0 and schSourceDesc = ''";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Map<String, String> querayOneCalenderData(int schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schID + " = " + schID;
        Map<String, String> noticeMap = null;

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<>();
                noticeMap.put(ScheduleTable.ID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.ID)));
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                if (noticeMap != null) break;
            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return noticeMap;
    }

    public Map<String, String> querayOneCalenderDataTitleId(String schSourceDesc) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schSourceDesc + " = '" + schSourceDesc + "'";
        Map<String, String> noticeMap = null;

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(ScheduleTable.ID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.ID)));
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                if (noticeMap != null) break;
            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return noticeMap;
    }

    /**
     * 根据id查询该日程是否已经结束
     */
    public Map<String, String> querayCalenderIsEnd(String schID) {
        String cisend = "0";
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schID + " = " + schID;
        Map<String, String> noticeMap = null;

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(ScheduleTable.ID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.ID)));
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        return noticeMap;
    }


    /**
     * 修改标签后将日程中该标签全部设0
     */
    public void setCalenderCololType(String colortype) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schColorType + " = " + 0 + " where "
                + ScheduleTable.schColorType + " = " + colortype;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public int isRead(String schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from " + ScheduleTable.ScheduleTable + " where " + ScheduleTable.schID + " = " + schID;
        int isRead = 0;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                isRead = cursor.getInt(cursor.getColumnIndex(ScheduleTable.schRead));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return isRead;
    }

    /**
     * 设置更新提醒日程的读取状态 0已读 1未读
     */
    public void updateReadState(int schID, int update) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRead + " = " + 0 + " , "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end) where "
                + ScheduleTable.schID + " = " + schID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateRead1State(String titleid, int update) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRead + " = " + 1 + " , "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end) where "
                + ScheduleTable.schSourceDesc + " = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单访问时间
     *
     * @param schID
     */
    public void updateSchSourceDescSpare(String schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schSourceDescSpare + " = '" + DateUtil.formatDateTimeSs(new Date()) + "', schUpdateState = (case schUpdateState when 0 then 2 else schUpdateState end) where "
                + ScheduleTable.schID + " = " + schID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getSchSourceDescSpare(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String swl = "select * from ScheduleTable where schSourceDesc = '" + titleid + "'";
        String time = DateUtil.formatDateTimeSs(new Date());
        try {
            Cursor cursor = sqldb.rawQuery(swl, null);
            while (cursor.moveToNext()) {
                time = cursor.getString(cursor.getColumnIndex(ScheduleTable.schSourceDescSpare));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return time;
    }

    /**
     * 修改清单访问时间
     */
    public void updateSchSourceDescSpare(String titleid, String time) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schSourceDescSpare + " = '" + time + "' where "
                + ScheduleTable.schSourceDesc + " = " + titleid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 设置更新提醒日程的读取状态 0已读 1未读
     */
    public void updateReadState1(int schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRead + " = " + 0 + " where "
                + ScheduleTable.schID + " = " + schID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 设置更新提醒日程的读取状态 0已读 1未读
     */
    public void updateRepeateReadState(int repID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repRead + " = " + 0 + " where "
                + CLRepeatTable.repID + " = " + repID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 将未结束代办的时间改为今天
     */
    public void updatedaiban() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        calendar.setTime(new Date());
        String today = DateUtil.formatDate(calendar.getTime());
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schDate + " = '" + today + "' where "
                + ScheduleTable.schDate + " <= '" + today + "' and "
                + ScheduleTable.schIsEnd + " != " + 1 + " and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and "
                + ScheduleTable.schDisplayTime + " != " + 1 + " and "
                + ScheduleTable.schIsPostpone + " != " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 将未结束，重复id=0，时间改为今天
     */
    public void updateshunyan() {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        calendar.setTime(new Date());
        String today = DateUtil.formatDate(calendar.getTime());
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schDate + " = '" + today + "' where "
                + ScheduleTable.schDate + " <= '" + today + "' and "
                + ScheduleTable.schRepeatID + " = 0 and "
                + ScheduleTable.schIsEnd + " != " + 1 + " and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and "
                + ScheduleTable.schDisplayTime + " = " + 1 + " and "
                + ScheduleTable.schIsPostpone + " = " + 1;
        String sql1 = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schDate + " = '" + today + "' where "
                + ScheduleTable.schDate + " <= '" + today + "' and "
                + ScheduleTable.schRepeatID + " != 0 and "
                + ScheduleTable.schIsEnd + " != " + 1 + " and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and "
                + ScheduleTable.schIsPostpone + " = " + 1;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 今天已结束数量
     */
    public int QueryTodayJieShuCount() {
        int result = 0;
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schIsEnd + " = " + 1 + " and "
                + ScheduleTable.schDate + " = '"
                + DateUtil.formatDate(new Date()) + "'and "
                + ScheduleTable.schUpdateState + " != " + 3;
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                result = cursor1.getInt(0);
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    /**
     * 过期未结束数量
     *
     * @return
     */
    public int QueryGuoQiWeiJieShuCount() {
        int result = 0;
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schIsEnd + " = " + 0 + " and "
                + ScheduleTable.schDate + " < '"
                + DateUtil.formatDate(new Date()) + "' and "
                + ScheduleTable.schIsPostpone + " != 1 and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and schColorType < 999999 ";
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                result = cursor1.getInt(0);
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    /**
     *
     */
    public String getCalenderContent(int id) {
        String content = "";
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schID + " = " + id;
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                content = cursor1.getString(cursor1.getColumnIndex("schContent"));
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            content = "";
        }

        return content;
    }

    public String getCalenderName(int id) {
        String content = "";
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schID + " = " + id;
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                content = cursor1.getString(cursor1.getColumnIndex("schcRecommendName"));
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            content = "";
        }

        return content;
    }

    /**
     *
     */
    /**
     * 查询过期未结束数量 和当前时间进行比较
     *
     * @return
     */
    public int QueryNowGuoQiWeiJieShuCount() {
        int result = 0;
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        /**
         * select count(*) from  ScheduleTable where schIsEnd = 0
         * and schDate <= '2016-12-06' and schTime < '19:37' and
         * schIsPostpone != 1 and schDisplayTime != 0 and schUpdateState != 3
         */
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schIsEnd + " != " + 1 + " and "
                + ScheduleTable.schDate + " || ' ' || " + ScheduleTable.schTime + " < '"
                + DateUtil.formatDateTime(new Date()) + "' and "
                + ScheduleTable.schIsPostpone + " != 1 and "
                + ScheduleTable.schDisplayTime + " != 0 and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and schColorType < 999999";
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                result = cursor1.getInt(0);
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    public int QueryNewNoteRedCount() {
        int result = 0;
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schIsEnd + " != " + 1 + " and schDate >= '" + DateUtil.formatDate(new Date()) + "' and schRead = 1 and schSourceDesc != '' and schUpdateState != 3";
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                result = cursor1.getInt(0);
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    public int QueryNewNoteRedHeadCount() {
        int result = 0;
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schDate + " >= '" + DateUtil.formatDate(new Date()) + "' and schRead = 1 and schSourceDesc != ''";
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            if (null != cursor1 && cursor1.getCount() > 0) {
                cursor1.moveToFirst();
                result = cursor1.getInt(0);
                cursor1.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    /**
     * 查询重复子记事是否已经存在
     *
     * @param content
     * @param nexttime
     * @param repeatid
     * @return
     */
    public boolean queryChildRepeatIsSave(String content, String nexttime, String repeatid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String[] time = nexttime.split(" ");

        String sql = "select * from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schRepeatDate + " > '" + nexttime + "' and "
                + ScheduleTable.schContent + " = '" + content + "' and "
                + ScheduleTable.schRepeatID + " = " + repeatid;
        boolean result = false;
        try {
            Cursor cursor1 = sqldb.rawQuery(sql, null);
            while (cursor1.moveToNext()) {
                cursor1.moveToFirst();
                result = true;
                break;
            }
            cursor1.close();
        } catch (Exception e) {
            e.printStackTrace();
            result = false;
        }
        return result;
    }

    /**
     * 修改过期未结束
     */
    public void updateEnd(String schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schIsEnd = 1, schUpdateState = 2 where schID = " + schID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改过期未结束
     */
    public void updateGuoQiWeiJieShu() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schIsEnd + " = " + 1 + " where "
                + ScheduleTable.schIsEnd + " = " + 0 + " and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and "
                + ScheduleTable.schDate + " < '"
                + DateUtil.formatDate(new Date()) + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改重要
     */
    public void updatImportant(int po, String schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schIsImportant + " = " + po + " where "
                + ScheduleTable.schID + " = " + schID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改重复标签
     */
    public void updateRepeatColorTypeState(String repID, String repColorType) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repColorType + " = " + repColorType + " where "
                + CLRepeatTable.repID + " = " + repID;
        Log.e("TAG", sql);
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateGuoQiWeiJieShu2() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schIsEnd + " = " + 1 + " where "
                + ScheduleTable.schIsEnd + " = " + 0 + " and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and "
                + ScheduleTable.schDate + " < '" + DateUtil.formatDate(new Date()) + "' and "
                + ScheduleTable.schcRecommendId + " <= " + 0;
        Log.e("TAG", sql);
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateScheduleTableschRemark12(String schRemark12, String schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRemark12 + " = '" + schRemark12 + "' where "
                + ScheduleTable.schID + " = " + schID;
        Log.e("TAG", sql);
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * @author li 新建日程 ScheduleTable 表名 schID 日程ID schContent 内容 schDate 日期
     * schTime 时间 schIsAlarm 是否有提醒 默认0无1有 schBeforeTime 提前时间 0
     * schDisplayTime 是否显示时间 0 schIsPostpone 是否顺延 0 schIsImportant 是否重要0
     * schColorType 颜色分类 0 schIsEnd 是否结束 0 schCreateTime 创建时间 schTags
     * 所在分类 "" schSourceType 来源分类(记录是否是链接)0 普通记事 schSourceDesc 来源描述(链接)
     * schSourceDescSpare 来源备用(链接描述) schRepeatID 重复ID schRepeatDate 重复时间
     * schUpdateTime 同步更新时间 schUpdateState 同步更新状态 schOpenState 打开状态
     * schRepeatLink 是否与母计时脱钩 0 schRingDesc 铃声描述 schRingCode 铃声编码
     * schcRecommendName 昵称
     */

    public boolean insertScheduleData(String schContent, String schDate,
                                      String schTime, int schIsAlarm, int schBeforeTime,
                                      int schDisplayTime, int schIsPostpone, int schIsImportant,
                                      int schColorType, int schIsEnd, String schCreateTime,
                                      String schTags, int schSourceType, String schSourceDesc,
                                      String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                      String schUpdateTime, int schUpdateState, int schOpenState,
                                      int schRepeatLink, String schRingDesc, String schRingCode,
                                      String schcRecommendName, int schRead, int schAID, int schAType,
                                      String schWebURL, String schImagePath, int schFocusState,
                                      int schFriendID, int schcRecommendId, int schpisEnd, String remark, String remark10, String remark11) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        schID = getScheduleTableMinId() - 1;
        String content = schContent
                .replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        int ID = getLocalId(1, "ScheduleTable", ScheduleTable.ID);
        String sql = "replace into ScheduleTable(ID, schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId,schpisEnd,schRemark1,schRemark10,schRemark11) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType == -1114 ? 0 : 2,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId, schpisEnd, remark, remark10, remark11};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean insertScheduleDataremark6(String schContent, String schDate,
                                             String schTime, int schIsAlarm, int schBeforeTime,
                                             int schDisplayTime, int schIsPostpone, int schIsImportant,
                                             int schColorType, int schIsEnd, String schCreateTime,
                                             String schTags, int schSourceType, String schSourceDesc,
                                             String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                             String schUpdateTime, int schUpdateState, int schOpenState,
                                             int schRepeatLink, String schRingDesc, String schRingCode,
                                             String schcRecommendName, int schRead, int schAID, int schAType,
                                             String schWebURL, String schImagePath, int schFocusState,
                                             int schFriendID, int schcRecommendId, int schpisEnd, String remark,
                                             String remark10, String remark11, String remark6) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        schID = getScheduleTableMinId() - 1;
        String content = schContent
                .replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        int ID = getLocalId(1, "ScheduleTable", ScheduleTable.ID);
        String sql = "replace into ScheduleTable(ID, schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId,schpisEnd,schRemark1,schRemark10,schRemark11,schRemark6) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType == -1114 ? 0 : 2,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId, schpisEnd, remark, remark10, remark11, remark6};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean insertTaskScheduleData(String schContent, String schDate,
                                          String schTime, int schIsAlarm, int schBeforeTime,
                                          int schDisplayTime, int schIsPostpone, int schIsImportant,
                                          int schColorType, int schIsEnd, String schCreateTime,
                                          String schTags, int schSourceType, String schSourceDesc,
                                          String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                          String schUpdateTime, int schUpdateState, int schOpenState,
                                          int schRepeatLink, String schRingDesc, String schRingCode,
                                          String schcRecommendName, int schRead, int schAID, int schAType,
                                          String schWebURL, String schImagePath, int schFocusState,
                                          int schFriendID, int schcRecommendId, int schpisEnd, String schRemark6, String remark2, String remark3) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        schID = getScheduleTableMinId() - 1;
        String content = schContent.replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        int ID = getLocalId(1, "ScheduleTable", ScheduleTable.ID);
        String sql = "replace into ScheduleTable(ID, schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId, schpisEnd,schRemark6,schRemark4,schRemark5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId, schpisEnd, schRemark6, remark2, remark3};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean insertTaskScheduleDataschID(String ID, String schID, String schContent, String schDate,
                                               String schTime, int schIsAlarm, int schBeforeTime,
                                               int schDisplayTime, int schIsPostpone, int schIsImportant,
                                               int schColorType, int schIsEnd, String schCreateTime,
                                               String schTags, int schSourceType, String schSourceDesc,
                                               String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                               String schUpdateTime, int schUpdateState, int schOpenState,
                                               int schRepeatLink, String schRingDesc, String schRingCode,
                                               String schcRecommendName, int schRead, int schAID, int schAType,
                                               String schWebURL, String schImagePath, int schFocusState,
                                               int schFriendID, int schcRecommendId, int schpisEnd, String remark6, String remark2, String remark3) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent
                .replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        String sql = "replace into ScheduleTable(ID, schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId, schpisEnd,schRemark6,schRemark4,schRemark5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId, schpisEnd, remark6, remark2, remark3};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean updataTaskScheduleData(int ID, int schID, String schContent, String schDate,
                                          String schTime, int schIsAlarm, int schBeforeTime,
                                          int schDisplayTime, int schIsPostpone, int schIsImportant,
                                          int schColorType, int schIsEnd, String schCreateTime,
                                          String schTags, int schSourceType, String schSourceDesc,
                                          String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                          String schUpdateTime, int schUpdateState, int schOpenState,
                                          int schRepeatLink, String schRingDesc, String schRingCode,
                                          String schcRecommendName, int schRead, int schAID, int schAType,
                                          String schWebURL, String schImagePath, int schFocusState,
                                          int schFriendID, int schcRecommendId, int schpisEnd) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent.replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        String sql = "update ScheduleTable set schID = " + schID + "," +
                "schContent = '" + StringUtils.getIsStringEqulesNull(content) + "'," +
                "schDate = '" + StringUtils.getIsStringEqulesNull(schDate) + "'," +
                "schTime = '" + StringUtils.getIsStringEqulesNull(schTime) + "'," +
                "schIsAlarm = " + schIsAlarm + ",schBeforeTime = " + schBeforeTime + "," +
                "schDisplayTime = " + schDisplayTime + ",schIsPostpone = " + schIsPostpone + "," +
                "schIsImportant = " + schIsImportant + ",schColorType = " + schColorType + "," +
                "schIsEnd = " + schIsEnd + ",schCreateTime = '" + StringUtils.getIsStringEqulesNull(schCreateTime) + "'," +
                "schTags = '" + StringUtils.getIsStringEqulesNull(schTags) + "'," +
                "schSourceType = " + schSourceType + ",schSourceDesc = '" + StringUtils.getIsStringEqulesNull(schSourceDesc) + "'," +
                "schSourceDescSpare = '" + StringUtils.getIsStringEqulesNull(schSourceDescSpare) + "',schRepeatID = " + schRepeatID + "," +
                "schRepeatDate = '" + StringUtils.getIsStringEqulesNull(schRepeatDate) + "', " +
                "schUpdateTime = '" + StringUtils.getIsStringEqulesNull(schUpdateTime) + "',schUpdateState = " + schUpdateState + "," +
                "schOpenState = " + schOpenState + ",schRepeatLink = " + schRepeatLink + "," +
                "schRingDesc = '" + StringUtils.getIsStringEqulesNull(schRingDesc) + "', " +
                "schRingCode = '" + StringUtils.getIsStringEqulesNull(schRingCode) + "'," +
                "schcRecommendName = '" + StringUtils.getIsStringEqulesNull(schcRecommendName) + "'," +
                "schRead = " + schRead + ",schAID = " + schAID + ",schAType = " + schAType + "," +
                "schWebURL = '" + StringUtils.getIsStringEqulesNull(schWebURL) + "'," +
                "schImagePath = '" + StringUtils.getIsStringEqulesNull(schImagePath) + "'," +
                "schFocusState = " + schFocusState + ",schFriendID = " + schFriendID + ",schcRecommendId = " + schcRecommendId + "," +
                "schFriendID = " + schpisEnd + "  where schSourceDesc = " + StringUtils.getIsStringEqulesNull(schSourceDesc);
        try {
            sqldb.execSQL(sql);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean updataTaskScheduleDataColor(String schID, String remark10, String remark11) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schRemark10 = '" + remark10 + "',schRemark11 = '" + remark11 + "' where schID = " + schID;
        try {
            sqldb.execSQL(sql);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean insertScheduleData(int ID, String schContent, String schDate,
                                      String schTime, int schIsAlarm, int schBeforeTime,
                                      int schDisplayTime, int schIsPostpone, int schIsImportant,
                                      int schColorType, int schIsEnd, String schCreateTime,
                                      String schTags, int schSourceType, String schSourceDesc,
                                      String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                      String schUpdateTime, int schUpdateState, int schOpenState,
                                      int schRepeatLink, String schRingDesc, String schRingCode,
                                      String schcRecommendName, int schRead, int schAID, int schAType,
                                      String schWebURL, String schImagePath, int schFocusState,
                                      int schFriendID, int schcRecommendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        schID = getLocalId(-1, "ScheduleTable", ScheduleTable.schID);
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "replace into ScheduleTable(ID, schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean insertScheduleData(String ID, String schID, String schContent, String schDate,
                                      String schTime, int schIsAlarm, int schBeforeTime,
                                      int schDisplayTime, int schIsPostpone, int schIsImportant,
                                      int schColorType, int schIsEnd, String schCreateTime,
                                      String schTags, int schSourceType, String schSourceDesc,
                                      String schSourceDescSpare, int schRepeatID, String schRepeatDate,
                                      String schUpdateTime, int schUpdateState, int schOpenState,
                                      int schRepeatLink, String schRingDesc, String schRingCode,
                                      String schcRecommendName, int schRead, int schAID, int schAType,
                                      String schWebURL, String schImagePath, int schFocusState,
                                      int schFriendID, int schcRecommendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "replace into ScheduleTable(ID, schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 查询日程TitleID是否存在
     *
     * @param titleid
     * @return
     */
    public Map<String, String> isCalenderTitleId(String titleid) {
        Map<String, String> result = null;
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from ScheduleTable where schSourceDesc = '" + titleid + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                result = new HashMap<>();
                result.put("schID", cursor.getString(cursor.getColumnIndex(ScheduleTable.schID)));
                result.put("ID", cursor.getString(cursor.getColumnIndex(ScheduleTable.ID)));
                result.put("schSourceDesc", cursor.getString(cursor.getColumnIndex(ScheduleTable.schSourceDesc)));
                result.put("schUpdateState", cursor.getString(cursor.getColumnIndex(ScheduleTable.schUpdateState)));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public void deleteTitleIdTask(String titleid, int schSourceType) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update ScheduleTable set schUpdateState = 3  where schSourceType = " + schSourceType + " and schSourceDesc = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteTitleIdTask(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update ScheduleTable set schUpdateState = 3  where schSourceDesc = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteChildRepeatTitleId(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from ScheduleTable where schSourceDesc = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteTaskTitleIdTask(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLRepeatTable set repUpdateState = 3 where repSourceDesc = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateTaskTitleIdTask(int repID, int repUpdateState) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLRepeatTable set repUpdateState = " + repUpdateState + " where repID = " + repID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateTaskTitleIdTaskRemark1(String image, int repID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLRepeatTable set remark1 = '" + image + "'  where repID = " + repID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Map<String, String> getSchReaId(String schID, boolean type) {

        Map<String, String> result = null;
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from ScheduleTable where " + (type ? "schRepeatID = " + schID : "schID = " + schID) + " and schUpdateState != 3 and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schTime desc limit 1";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = new HashMap<>();
                result.put("schRepeatID", cursor.getString(cursor.getColumnIndex(ScheduleTable.schRepeatID)));
                result.put("schTime", cursor.getString(cursor.getColumnIndex(ScheduleTable.schTime)));
                result.put("schDate", cursor.getString(cursor.getColumnIndex(ScheduleTable.schDate)));
                result.put("schID", cursor.getString(cursor.getColumnIndex(ScheduleTable.schID)));
                result.put("schIsEnd", cursor.getString(cursor.getColumnIndex(ScheduleTable.schIsEnd)));
                result.put("repNextCreatedTime", cursor.getString(cursor.getColumnIndex(ScheduleTable.schDate))
                        + " " + cursor.getString(cursor.getColumnIndex(ScheduleTable.schTime)));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }


    /**
     * 网上下载，没有的下载插入
     */
    public boolean insertIntenetScheduleData(Integer id, String schContent,
                                             String schDate, String schTime, Integer schIsAlarm,
                                             Integer schBeforeTime, Integer schDisplayTime,
                                             Integer schIsPostpone, Integer schIsImportant,
                                             Integer schColorType, Integer schIsEnd, String schCreateTime,
                                             String schTags, Integer schSourceType, String schSourceDesc,
                                             String schSourceDescSpare, Integer schRepeatID,
                                             String schRepeatDate, String schUpdateTime, Integer schUpdateState,
                                             Integer schOpenState, Integer schRepeatLink, String schRingDesc,
                                             String schRingCode, String schcRecommendName, int schRead,
                                             int schAID, int schAType, String schWebURL, String schImagePath,
                                             int schFocusState, int schFriendID, int schcRecommendId, int pIsEnd,
                                             String remark1, String remark2, String remark3, String remark4, String remark5, String remark7
            , String remark10, String remark11, String remark12) {
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int ID = getLocalId(1, "ScheduleTable", ScheduleTable.ID);
        String sql = "replace into ScheduleTable(ID,schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId,schpisEnd,schRemark1,schRemark2,schRemark3," +
                "schRemark4,schRemark5,schRemark7,schRemark10,schRemark11,schRemark12) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, id,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId, pIsEnd, remark1, remark2, remark3, remark4, remark5, remark7, remark10, remark11, remark12};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 获取某表,某字段的最大值
     *
     * @param type          1需要正值,-1需要负值
     * @param tableName     表名
     * @param maxColumnName 要查询最大值的字段名
     * @return
     */
    public int getLocalId(int type, String tableName, String maxColumnName) {
        int result = 0;
        if (type == 1) {
            SQLiteDatabase sqldb = helper.getWritableDatabase();
            try {
                String sql = "select max(" + maxColumnName + ") from " + tableName;
                Cursor cursor = sqldb.rawQuery(sql, null);
                if (null != cursor && cursor.getCount() > 0) {
                    cursor.moveToFirst();
                    result = cursor.getInt(0) + 1;
                    if (result < 0) {
                        result = 1;
                    }
                    cursor.close();
                } else {
                    result = 1;
                }
            } catch (Exception e) {
                result = 1;
            }
        } else if (type == -1) {
            SQLiteDatabase sqldb = helper.getWritableDatabase();
            try {
                String sql = "select min(" + maxColumnName + ") from " + tableName;
                Cursor cursor = sqldb.rawQuery(sql, null);
                if (null != cursor && cursor.getCount() > 0) {
                    cursor.moveToFirst();
                    result = cursor.getInt(0);
                    if (result >= 0) {
                        result = -1;
                    } else {
                        result = result - 1;
                    }
                    cursor.close();
                } else {
                    result = -1;
                }
            } catch (Exception e) {
                result = -1;
            }
        }
        return result;
    }

    /**
     * 本地删除，就是修改updateState的状态值
     *
     * @param schId
     */
    public void deleteScheduleLocalData(String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int id = Integer.parseInt(schId);
        String sql;
        if (id < 0) {
            sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                    + ScheduleTable.schID + " = " + schId;
        } else {
            sql = "update " + ScheduleTable.ScheduleTable + " set "
                    + ScheduleTable.schUpdateState + " = " + 3 + " where "
                    + ScheduleTable.schID + " = " + schId + " and "
                    + ScheduleTable.schUpdateState + " != " + 3;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateScheduleLocalDataschRemark3(String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int id = Integer.parseInt(schId);
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRemark3 + " = '1' where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 和网上同步删除
     *
     * @param schId
     */
    public void deleteScheduleData(Integer schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteScheduleData(String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改铃声
     *
     * @param schId
     * @param schRingDesc
     * @param schRingCode
     */
    public void updateSceduleDataLingsheng(int schId, String schRingDesc,
                                           String schRingCode) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schRingDesc = '" + schRingDesc + "', schRingCode = '" + schRingCode + "' where " + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改日期
     *
     * @param schId
     * @param schDate
     */
    public void updateSceduleDataDate(String schId, String schDate) {
        if (schDate.length() > 10) {
            schDate = schDate.substring(1, schDate.length() - 1);
        }
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schDate = '" + schDate + "' where " + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 代办置顶
     *
     * @param schId
     * @param schTime
     * @param schDate
     */
    public void updateSceduleDataTop(String schId, String schTime, String schDate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schTime = '" + schTime + "',schDate = '" + schDate + "' where " + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改时间
     *
     * @param schId
     * @param schTime
     * @param schDisplayTime
     */
    public void updateSceduleDataTime(String schId, String schTime, int schDisplayTime) {
        if (schTime.length() > 5) {
            schTime = schTime.substring(1, schTime.length() - 1);
        }
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schTime = '" + schTime + "',schDisplayTime = " + schDisplayTime + " where " + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 将重复子记事标记为新增普通日程
     *
     * @param schId
     */
    public void updateSchuledRepeatTo(String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schUpdateState = 1 where " + ScheduleTable.schID + " = " + schId;
        //schRepeatID = 0 ,schRepeatDate = '' , schRepeatLink = 0 ,
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改提前提醒时间
     *
     * @param schId
     * @param schBeforeTime
     * @param schIsAlarm
     */
    public void updateSceduleDataTiQianTime(int schId, int schBeforeTime, int schIsAlarm) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schBeforeTime = " + schBeforeTime + ", schIsAlarm = " + schIsAlarm + " where " + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改普通日程
     *
     * @return
     */
    public void updateScheduleData(int schId, String schContent,
                                   String schDate, String schTime, int schIsAlarm, int schBeforeTime,
                                   int schDisplayTime, int schIsPostpone, int schIsImportant,
                                   int schColorType, int schIsEnd, String schTags, int schSourceType,
                                   String schSourceDesc, String schSourceDescSpare, int schRepeatID,
                                   String schRepeatDate, String schUpdateTime, int schUpdateState,
                                   int schOpenState, int schRepeatLink, String schRingDesc,
                                   String schRingCode, String schcRecommendName, int schRead,
                                   int schAID, int schAType, String schWebURL, String schImagePath,
                                   int schFocusState, int schFriendID, int schcRecommendId, int pIsEnd,
                                   String remark1, String remark2, String remark3, String remark4,
                                   String remark5, String remark7, String remark10, String remark11, String remark12) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "update ScheduleTable set " + ScheduleTable.schContent
                + " = ? " + "," + ScheduleTable.schDate + " = ? " + ", "
                + ScheduleTable.schTime + " = ?" + ", "
                + ScheduleTable.schIsAlarm + " = ?" + ", "
                + ScheduleTable.schBeforeTime + " = ?" + ", "
                + ScheduleTable.schDisplayTime + " = ?" + ", "
                + ScheduleTable.schIsPostpone + " = ?" + ", "
                + ScheduleTable.schIsImportant + " = ?" + ", "
                + ScheduleTable.schColorType + " = ?" + ", "
                + ScheduleTable.schIsEnd + " = ?" + ", "
                + ScheduleTable.schTags + " = ?" + ", "
                + ScheduleTable.schSourceType + " = ?" + ", "
                + ScheduleTable.schSourceDesc + " = ?" + ", "
                + ScheduleTable.schSourceDescSpare + " = ?" + ", "
                + ScheduleTable.schRepeatID + " = ?" + ", "
                + ScheduleTable.schRepeatDate + " = ?" + ", "
                + ScheduleTable.schUpdateTime + " = ?" + ", "
                + ScheduleTable.schUpdateState + " = ?" + ", "
                + ScheduleTable.schOpenState + " = ?" + ", "
                + ScheduleTable.schRepeatLink + " = ?" + ", "
                + ScheduleTable.schRingDesc + " = ?" + ", "
                + ScheduleTable.schRingCode + " = ?" + ", "
                + ScheduleTable.schcRecommendName + " = ?" + ", "
                + ScheduleTable.schRead + " = ?" + ", " + ScheduleTable.schAID
                + " = ?" + ", " + ScheduleTable.schAType + " = ?" + ", "
                + ScheduleTable.schWebURL + " = ?" + ", "
                + ScheduleTable.schImagePath + " = ?" + ", "
                + ScheduleTable.schFocusState + " = ?" + ", "
                + ScheduleTable.schFriendID + " = ?" + ", "
                + ScheduleTable.schpisEnd + " = ?" + ", "
                + ScheduleTable.schRemark1 + " = ?" + ", "
                + ScheduleTable.schRemark2 + " = ?" + ", "
                + ScheduleTable.schRemark3 + " = ?" + ", "
                + ScheduleTable.schRemark4 + " = ?" + ", "
                + ScheduleTable.schRemark5 + " = ?" + ", "
                + ScheduleTable.schRemark7 + " = ?" + ", "
                + ScheduleTable.schRemark10 + " = ?" + ", "
                + ScheduleTable.schRemark11 + " = ?" + ", "
                + ScheduleTable.schRemark12 + " = ?" + ", "
                + ScheduleTable.schcRecommendId + " = ? " + " where "
                + ScheduleTable.schID + " = " + schId;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, pIsEnd, remark1, remark2, remark3, remark4,
                remark5, remark7, remark10, remark11, remark12, schcRecommendId};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void updateScheduleCalenderNoteData(String schId, String schContent,
                                               String schDate, String schTime, int schIsAlarm, int schBeforeTime,
                                               int schDisplayTime, int schIsPostpone, String schRingDesc,
                                               String schRingCode, String schImagePath, String schSourceDesc, int schSourceDescSpare, int schRepeatID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent.replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        Map<String, String> map = isCalenderTitleId(schSourceDesc);
        int schUpdateState = 2;
        if (map != null && map.get(ScheduleTable.schUpdateState).equals("1")) {
            schUpdateState = 1;
        }
        String sql = "update ScheduleTable set "
                + ScheduleTable.schRepeatID + " = ? " + ","
                + ScheduleTable.schContent + " = ? " + ","
                + ScheduleTable.schDate + " = ? " + ", "
                + ScheduleTable.schTime + " = ?" + ", "
                + ScheduleTable.schIsAlarm + " = ?" + ", "
                + ScheduleTable.schBeforeTime + " = ?" + ", "
                + ScheduleTable.schDisplayTime + " = ?" + ", "
                + ScheduleTable.schIsPostpone + " = ?" + ", "
                + ScheduleTable.schSourceDesc + " = ?" + ", "
                + ScheduleTable.schRingDesc + " = ?" + ", "
                + ScheduleTable.schRingCode + " = ?" + ", "
                + ScheduleTable.schImagePath + " = ?" + ", "
                + ScheduleTable.schSourceDescSpare + " = ?" + ", "
                + ScheduleTable.schSourceType + " = ?" + ", "
                + ScheduleTable.schUpdateState + " = ? where "
                + ScheduleTable.schID + " = " + schId;
        Object[] mValue = new Object[]{schRepeatID,
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schImagePath), schSourceDescSpare, 2, schUpdateState};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 留言修改普通日程
     *
     * @return
     */
    public void updateScheduleData2(int schId, String schContent,
                                    String schRingCode, String schRingDesc, int schIsPostpone, int schAType,
                                    String schBeforeTime, String schIsAlarm, String schTime,
                                    String schDisplayTime, String schWebURL, String schCreateTime, String schDate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "update ScheduleTable set "
                + ScheduleTable.schContent + " = ? " + ","
                + ScheduleTable.schRingCode + " = ? " + ","
                + ScheduleTable.schRingDesc + " = ? " + ","
                + ScheduleTable.schIsPostpone + " = ? " + ","
                + ScheduleTable.schAType + " = ? " + ","
                + ScheduleTable.schBeforeTime + " = ? " + ","
                + ScheduleTable.schIsAlarm + " = ? " + ","
                + ScheduleTable.schTime + " = ? " + ","
                + ScheduleTable.schDisplayTime + " = ? " + ","
                + ScheduleTable.schWebURL + " = ? " + ","
                + ScheduleTable.schCreateTime + " = ? " + ","
                + ScheduleTable.schDate + " = ? "
                + " where "
                + ScheduleTable.schID + " = " + schId;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schRingDesc),
                schIsPostpone,
                schAType,
                StringUtils.getIsStringEqulesNull(schBeforeTime),
                StringUtils.getIsStringEqulesNull(schIsAlarm),
                StringUtils.getIsStringEqulesNull(schTime),
                StringUtils.getIsStringEqulesNull(schDisplayTime),
                StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schCreateTime),
                StringUtils.getIsStringEqulesNull(schDate)};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 和网上同步成功后修改状态值为0
     */
    public void updateUpdateState(Integer schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schUpdateState + " = " + 0 + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 和网上同步失败后修改状态值为-1
     */
    public void updateUpdateStateFaild(Integer schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schUpdateState + " = " + -1 + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改日程状态
     *
     * @param schId
     * @param type
     */
    public void updateUpdateStateFaild(Integer schId, int type) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schUpdateState + " = " + type + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改日程内容
     */
    public void updateUpdateSchContent(String schContent, String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end),"
                + ScheduleTable.schContent + " = '" + schContent + "' where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改转发人
     */
    public void updateUpdateSchschTags(String schTags, String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end),"
                + ScheduleTable.schTags + " = '" + schTags + "' where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 更改日程推迟时间
     */
    public void updateScheduleDateData(int schId, String schDate, String schTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schDate + " = '" + schDate + "', "
                + ScheduleTable.schTime + " = '" + schTime + "', "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end) where "
                + ScheduleTable.schID + " = " + schId + " and "
                + ScheduleTable.schUpdateState + " != " + 3;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改openstate状态
     */
    /**
     * 更改日程推迟时间
     */
    public void updateScheduleOpenStateData(String id, int state) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schOpenState + " = " + state + ", "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end) where "
                + ScheduleTable.schID + " = " + id + " and "
                + ScheduleTable.schUpdateState + " != " + 3;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改为待办 今天+全天+顺延
     */
    public void updateScheduleUnTaskData(String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schDate + " = '"
                + DateUtil.formatDate(new Date()) + "', "
                + ScheduleTable.schDisplayTime + " = " + 0 + ", "
                + ScheduleTable.schIsPostpone + " = " + 1 + ", "
                + ScheduleTable.schUpdateState + " = (case schUpdateState when 0 then 2 else schUpdateState end) where "
                + ScheduleTable.schID + " = " + schId + " and "
                + ScheduleTable.schUpdateState + " != " + 3;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改是否结束
     *
     * @return
     */
    @SuppressWarnings("unchecked")
    public void updateScheduleData(Map<String, String> upMap, String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + " = "
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + " = '"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String[] str = updateStr.split(",");
        String updateState = str[0].toString();
        String schIsEnd = str[1].toString();
        String sql = "update " + ScheduleTable.ScheduleTable + " set schUpdateState = (case schUpdateState when 0 then 2 else schUpdateState end) , " + schIsEnd + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @SuppressWarnings("unchecked")
    public void updateScheduleData1(Map<String, String> upMap, String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + "="
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + "='"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String sql = "update " + ScheduleTable.ScheduleTable + " set schUpdateState = (case schUpdateState when 0 then 2 else schUpdateState end),"
                + updateStr + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改schread状态
     */
    public void updateSchReadData(int schId, int schread) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRead + " = " + schread + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改schRepeatLink 的值
     */
    public void updateSchRepeatLinkData(int schId, int link) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRepeatLink + " = " + link + " where "
                + ScheduleTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 验证一个字符串是不是数字
     *
     * @param str
     * @return
     */
    public static boolean isNum(String str) {
        if ("".equals(str))
            return false;
        return str.matches("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$");
    }

    public static void initImageLoader(Context context) {
        // This configuration tuning is custom. You can tune every option, you
        // may tune some of them,
        // or you can create default configuration by
        // ImageLoaderConfiguration.createDefault(this);
        // method.
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                context).threadPriority(Thread.NORM_PRIORITY - 2)
                .denyCacheImageMultipleSizesInMemory()
                .discCacheFileNameGenerator(new Md5FileNameGenerator())
                .tasksProcessingOrder(QueueProcessingType.LIFO)
                // .writeDebugLogs() // Remove for release app
                .build();
        // Initialize ImageLoader with configuration.
        ImageLoader.getInstance().init(config);
    }

    /**
     * 修改日程ID
     */
    public void UpdateSchID(Integer SchID, Integer newid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update ScheduleTable set schID = " + newid
                + " where schID = " + SchID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改日程ID
     */
    public void UpdateSchschRepeatID(Integer schRepeatID, Integer newid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update ScheduleTable set schRepeatID = " + newid
                + " where schRepeatID = " + schRepeatID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 查询数据库是否有相同id的数据
     */
    public int CheckCountSchData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schID + " = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 根据重复id查询重复类型
     *
     * @return
     */
    public Map<String, String> queryRepateType(String repid) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> sMap = new HashMap<String, String>();
        String sql = "select * from CLRepeatTable where repID ='" + repid + "'";

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (cursor.getCount() > 0) {
                if (cursor.moveToNext()) {
                    sMap.put("type", cursor.getString(cursor.getColumnIndex(CLRepeatTable.repType)));
                    return sMap;
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return sMap;

    }

    /**
     * 修改闹钟日程是否结束
     */
    @SuppressWarnings("unchecked")
    public void updateSchFocusState(Map<String, String> upMap, String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + " = "
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + " = '"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String[] str = updateStr.split(",");
        String isEnd = str[0].toString();
        String sql = "update " + ScheduleTable.ScheduleTable + " set " + isEnd
                + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 查询搜索到的日程数据 1 两天以前 2 昨天 3今天 4明天 5一周以内 6一周以后
     */
    public List<Map<String, String>> QuerySchSerachData(int index,
                                                        String content) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "";
        String yestoday;// 昨天
        String today;// 今天
        String tomorrow;// 明天
        String inweek;// 一周以内
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        yestoday = DateUtil.formatDate(calendar.getTime());
        calendar.setTime(new Date());
        today = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 1);
        tomorrow = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 7);
        inweek = DateUtil.formatDate(calendar.getTime());
        switch (index) {
            case 1:// 两天以前
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schContent + " like '%" + content
                        + "%' and " + ScheduleTable.schUpdateState + " != " + 3
                        + " and " + ScheduleTable.schDate + " < '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 2:// 昨天
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schContent + " like '%" + content
                        + "%' and " + ScheduleTable.schUpdateState + " != " + 3
                        + " and " + ScheduleTable.schDate + " = '" + yestoday
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 3:// 今天
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schContent + " like '%" + content
                        + "%' and " + ScheduleTable.schUpdateState + " != " + 3
                        + " and " + ScheduleTable.schDate + " = '" + today
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 4:// 明天
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schContent + " like '%" + content
                        + "%' and " + ScheduleTable.schUpdateState + " != " + 3
                        + " and " + ScheduleTable.schDate + " = '" + tomorrow
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 5:// 一周以内
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schContent + " like '%" + content
                        + "%' and " + ScheduleTable.schUpdateState + " != " + 3
                        + " and " + ScheduleTable.schDate + " > '" + tomorrow
                        + "' and " + ScheduleTable.schDate + " < '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            case 6:// 一周以后
                sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                        + ScheduleTable.schContent + " like '%" + content
                        + "%' and " + ScheduleTable.schUpdateState + " != " + 3
                        + " and " + ScheduleTable.schDate + " >= '" + inweek
                        + "'   and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
                break;
            default:
                break;
        }
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if ((m1.get(ScheduleTable.schSourceType).equals("3") && m2.get(ScheduleTable.schSourceType).equals("3")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("4") && m2.get(ScheduleTable.schSourceType).equals("4")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("5") && m2.get(ScheduleTable.schSourceType).equals("5"))) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc))) {
                        dataList.remove(j);
                        continue;
                    }
                }

                if (m1.get(ScheduleTable.schSourceType).equals("2") && m2.get(ScheduleTable.schSourceType).equals("2")) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc)) && !m1.get(ScheduleTable.schcRecommendName).isEmpty()) {
                        dataList.remove(j - 1);
                        continue;
                    }
                }
            }
        }
        return dataList;
    }

    /*********************************
     * 重复数据库操作
     ************************************************/
    public boolean insertCLRepeatTableData(int repBeforeTime, int repColorType,
                                           int repDisplayTime, int repType, int repIsAlarm, int repIsPuase,
                                           int repIsImportant, int repSourceType, int repUpdateState,
                                           String repTypeParameter, String repNextCreatedTime,
                                           String repLastCreatedTime, String repInitialCreatedTime,
                                           String repStartDate, String repContent, String repCreateTime,
                                           String repSourceDesc, String repSourceDescSpare, String repTime,
                                           String repRingDesc, String repRingCode, String repUpdateTime,
                                           int repOpenState, String repCommendedUserName,
                                           int repCommendedUserId, String repDateOne, String repDateTwo,
                                           int repStateOne, int repStateTwo, int repAType, String repWebURL,
                                           String repImagePath, int repInSTable, int repEndState,
                                           String parReamrk, int repRead, int repPostState, String dataType, String dataId, String remark1,
                                           String remark2, String remark3, String remark4, String remark5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = repContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        int repID = getLocalId(-1, "CLRepeatTable", CLRepeatTable.repID);
        repschId = repID;
        String sql = "replace into CLRepeatTable(repID,repBeforeTime, repColorType,repDisplayTime,"
                + "repType,repIsAlarm,repIsPuase,repIsImportant,repSourceType,repUpdateState,"
                + "repTypeParameter, repNextCreatedTime,repLastCreatedTime,repInitialCreatedTime,"
                + "repStartDate,repContent, repCreateTime,repSourceDesc, repSourceDescSpare, "
                + "repTime,repRingDesc, repRingCode,repUpdateTime,repOpenState, "
                + "repCommendedUserName,repCommendedUserId, repDateOne, repDateTwo,"
                + "repStateOne,repStateTwo,repAType, repWebURL,repImagePath,repInSTable,"
                + "repEndState,parReamrk,repRead,repPostState,dataType,dataId,remark1,remark2,remark3,remark4,remark5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{repID, repBeforeTime, repColorType,
                repDisplayTime, repType, repIsAlarm, repIsPuase,
                repIsImportant, repSourceType, repUpdateState,
                StringUtils.getIsStringEqulesNull(repTypeParameter),
                StringUtils.getIsStringEqulesNull(repNextCreatedTime),
                StringUtils.getIsStringEqulesNull(repLastCreatedTime),
                StringUtils.getIsStringEqulesNull(repInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(repStartDate),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(repCreateTime),
                StringUtils.getIsStringEqulesNull(repSourceDesc),
                StringUtils.getIsStringEqulesNull(repSourceDescSpare),
                StringUtils.getIsStringEqulesNull(repTime),
                StringUtils.getIsStringEqulesNull(repRingDesc),
                StringUtils.getIsStringEqulesNull(repRingCode),
                StringUtils.getIsStringEqulesNull(repUpdateTime), repOpenState,
                StringUtils.getIsStringEqulesNull(repCommendedUserName),
                repCommendedUserId,
                StringUtils.getIsStringEqulesNull(repDateOne),
                StringUtils.getIsStringEqulesNull(repDateTwo), repStateOne,
                repStateTwo, repAType,
                StringUtils.getIsStringEqulesNull(repWebURL),
                StringUtils.getIsStringEqulesNull(repImagePath), repInSTable,
                repEndState, StringUtils.getIsStringEqulesNull(parReamrk),
                repRead, repPostState, dataType, dataId, remark1, remark2, remark3, remark4, remark5};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }


    public boolean updataCLRepeatTableData(String repid, int repBeforeTime, int repColorType,
                                           int repDisplayTime, int repType, int repIsAlarm, int repIsPuase,
                                           int repIsImportant, int repSourceType, int repUpdateState,
                                           String repTypeParameter, String repNextCreatedTime,
                                           String repLastCreatedTime, String repInitialCreatedTime,
                                           String repStartDate, String repContent, String repCreateTime,
                                           String repSourceDesc, String repSourceDescSpare, String repTime,
                                           String repRingDesc, String repRingCode, String repUpdateTime,
                                           int repOpenState, String repCommendedUserName,
                                           int repCommendedUserId, String repDateOne, String repDateTwo,
                                           int repStateOne, int repStateTwo, int repAType, String repWebURL,
                                           String repImagePath, int repInSTable, int repEndState,
                                           String parReamrk, int repRead, int repPostState, String dataType, String dataId, String remark1,
                                           String remark2, String remark3, String remark4, String remark5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = repContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "replace into CLRepeatTable(repID,repBeforeTime, repColorType,repDisplayTime,"
                + "repType,repIsAlarm,repIsPuase,repIsImportant,repSourceType,repUpdateState,"
                + "repTypeParameter, repNextCreatedTime,repLastCreatedTime,repInitialCreatedTime,"
                + "repStartDate,repContent, repCreateTime,repSourceDesc, repSourceDescSpare, "
                + "repTime,repRingDesc, repRingCode,repUpdateTime,repOpenState, "
                + "repCommendedUserName,repCommendedUserId, repDateOne, repDateTwo,"
                + "repStateOne,repStateTwo,repAType, repWebURL,repImagePath,repInSTable,"
                + "repEndState,parReamrk,repRead,repPostState,dataType,dataId,remark1,remark2,remark3,remark4,remark5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{repid, repBeforeTime, repColorType,
                repDisplayTime, repType, repIsAlarm, repIsPuase,
                repIsImportant, repSourceType, repUpdateState,
                StringUtils.getIsStringEqulesNull(repTypeParameter),
                StringUtils.getIsStringEqulesNull(repNextCreatedTime),
                StringUtils.getIsStringEqulesNull(repLastCreatedTime),
                StringUtils.getIsStringEqulesNull(repInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(repStartDate),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(repCreateTime),
                StringUtils.getIsStringEqulesNull(repSourceDesc),
                StringUtils.getIsStringEqulesNull(repSourceDescSpare),
                StringUtils.getIsStringEqulesNull(repTime),
                StringUtils.getIsStringEqulesNull(repRingDesc),
                StringUtils.getIsStringEqulesNull(repRingCode),
                StringUtils.getIsStringEqulesNull(repUpdateTime), repOpenState,
                StringUtils.getIsStringEqulesNull(repCommendedUserName),
                repCommendedUserId,
                StringUtils.getIsStringEqulesNull(repDateOne),
                StringUtils.getIsStringEqulesNull(repDateTwo), repStateOne,
                repStateTwo, repAType,
                StringUtils.getIsStringEqulesNull(repWebURL),
                StringUtils.getIsStringEqulesNull(repImagePath), repInSTable,
                repEndState, StringUtils.getIsStringEqulesNull(parReamrk),
                repRead, repPostState, dataType, dataId, remark1, remark2, remark3, remark4, remark5};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public boolean insertSendRepeatNoteTableData(int id, int uId,
                                                 int ctype, int ptype, int puId, int pDeleState,
                                                 int repInSTable, int repType, int cBeforTime, int cDisplayAlarm, int cPostpone,
                                                 int cImportant, int pIsEnd,
                                                 int cIsEnd, int styles, int cIsDown,
                                                 int cColorType, String uname, String pname,
                                                 String titleImg, String content, String cdate,
                                                 String ctime, String repTypeParameter,
                                                 String cIsAlarm, String cAlarmSound, String cAlarmSoundDesc,
                                                 String createTime, String changTime, String titleId, String remark, String remark1,
                                                 String remark2, String remark3, String remark4, String remark5, String remark6) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String contents = content.replaceAll(
                "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        String sql = "replace into tb_user_frends_task(id,uId, ctype,ptype,"
                + "puId,pDeleState,repInSTable,repType,cBeforTime,cDisplayAlarm,"
                + "cPostpone, cImportant,pIsEnd,cIsEnd,"
                + "styles,cIsDown, cColorType,uname, pname, "
                + "titleImg,content, cdate,ctime,repTypeParameter, "
                + "cIsAlarm,cAlarmSound, cAlarmSoundDesc, createTime,"
                + "changTime,titleId,remark, remark1,remark2,remark3,"
                + "remark4,remark5,remark6) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{id, uId, ctype,
                ptype, puId, pDeleState, repInSTable,
                repType, cBeforTime, cDisplayAlarm, cPostpone, cImportant,
                pIsEnd, cIsEnd, styles, cIsDown, cColorType,
                StringUtils.getIsStringEqulesNull(uname),
                StringUtils.getIsStringEqulesNull(pname),
                StringUtils.getIsStringEqulesNull(titleImg),
                StringUtils.getIsStringEqulesNull(contents),
                StringUtils.getIsStringEqulesNull(cdate),
                StringUtils.getIsStringEqulesNull(ctime),
                StringUtils.getIsStringEqulesNull(repTypeParameter),
                StringUtils.getIsStringEqulesNull(cIsAlarm),
                StringUtils.getIsStringEqulesNull(cAlarmSound),
                StringUtils.getIsStringEqulesNull(cAlarmSoundDesc),
                StringUtils.getIsStringEqulesNull(createTime),
                StringUtils.getIsStringEqulesNull(changTime),
                StringUtils.getIsStringEqulesNull(titleId),
                StringUtils.getIsStringEqulesNull(remark),
                StringUtils.getIsStringEqulesNull(remark1),
                StringUtils.getIsStringEqulesNull(remark2),
                StringUtils.getIsStringEqulesNull(remark3),
                StringUtils.getIsStringEqulesNull(remark4),
                StringUtils.getIsStringEqulesNull(remark5),
                StringUtils.getIsStringEqulesNull(remark6)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 查询某一条重复
     *
     * @param repId
     * @return
     */
    public Map<String, String> QueryhongFuData(String repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                + CLRepeatTable.repID + " = " + repId;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLRepeatTable.repID, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repID)));
                noticeMap.put(CLRepeatTable.repBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repBeforeTime)));
                noticeMap.put(CLRepeatTable.repColorType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repColorType)));
                noticeMap.put(CLRepeatTable.repDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repDisplayTime)));
                noticeMap.put(CLRepeatTable.repType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repType)));
                noticeMap.put(CLRepeatTable.repIsAlarm, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsAlarm)));
                noticeMap.put(CLRepeatTable.repIsPuase, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsPuase)));
                noticeMap.put(CLRepeatTable.repIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repIsImportant)));
                noticeMap.put(CLRepeatTable.repSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceType)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap
                        .put(CLRepeatTable.repTypeParameter,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repTypeParameter)));
                noticeMap
                        .put(CLRepeatTable.repNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repNextCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repLastCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repInitialCreatedTime)));
                noticeMap.put(CLRepeatTable.repStartDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStartDate)));
                noticeMap.put(CLRepeatTable.repContent, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repContent)));
                noticeMap.put(CLRepeatTable.repCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repCreateTime)));
                noticeMap.put(CLRepeatTable.repSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceDesc)));
                noticeMap
                        .put(CLRepeatTable.repSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repSourceDescSpare)));
                noticeMap.put(CLRepeatTable.repTime, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repTime)));
                noticeMap.put(CLRepeatTable.repRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingDesc)));
                noticeMap.put(CLRepeatTable.repRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingCode)));
                noticeMap.put(CLRepeatTable.repUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateTime)));
                noticeMap.put(CLRepeatTable.repOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repOpenState)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserName,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserName)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserId)));
                noticeMap.put(CLRepeatTable.repDateOne, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateOne)));
                noticeMap.put(CLRepeatTable.repDateTwo, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateTwo)));
                noticeMap.put(CLRepeatTable.repStateOne, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateOne)));
                noticeMap.put(CLRepeatTable.repStateTwo, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateTwo)));
                noticeMap.put(CLRepeatTable.repAType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repAType)));
                noticeMap.put(CLRepeatTable.repWebURL, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repWebURL)));
                noticeMap.put(CLRepeatTable.repImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repImagePath)));
                noticeMap.put(CLRepeatTable.repInSTable, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repInSTable)));
                noticeMap.put(CLRepeatTable.repEndState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repEndState)));
                noticeMap.put(CLRepeatTable.parReamrk, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.parReamrk)));
                noticeMap.put(CLRepeatTable.repRead, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repRead)));
                noticeMap.put(CLRepeatTable.repPostState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repPostState)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap.put(CLRepeatTable.dataType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataType)));
                noticeMap.put(CLRepeatTable.dataId, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataId)));
                noticeMap.put(CLRepeatTable.remark1, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark1)));
                noticeMap.put(CLRepeatTable.remark2, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark2)));
                noticeMap.put(CLRepeatTable.remark3, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark3)));
                noticeMap.put(CLRepeatTable.remark4, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark4)));
                noticeMap.put(CLRepeatTable.remark5, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark5)));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    public Map<String, String> QueryhongFuDatatitleid(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                + CLRepeatTable.repSourceDesc + " = '" + titleid + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLRepeatTable.repID, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repID)));
                noticeMap.put(CLRepeatTable.repBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repBeforeTime)));
                noticeMap.put(CLRepeatTable.repColorType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repColorType)));
                noticeMap.put(CLRepeatTable.repDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repDisplayTime)));
                noticeMap.put(CLRepeatTable.repType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repType)));
                noticeMap.put(CLRepeatTable.repIsAlarm, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsAlarm)));
                noticeMap.put(CLRepeatTable.repIsPuase, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsPuase)));
                noticeMap.put(CLRepeatTable.repIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repIsImportant)));
                noticeMap.put(CLRepeatTable.repSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceType)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap
                        .put(CLRepeatTable.repTypeParameter,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repTypeParameter)));
                noticeMap
                        .put(CLRepeatTable.repNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repNextCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repLastCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repInitialCreatedTime)));
                noticeMap.put(CLRepeatTable.repStartDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStartDate)));
                noticeMap.put(CLRepeatTable.repContent, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repContent)));
                noticeMap.put(CLRepeatTable.repCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repCreateTime)));
                noticeMap.put(CLRepeatTable.repSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceDesc)));
                noticeMap
                        .put(CLRepeatTable.repSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repSourceDescSpare)));
                noticeMap.put(CLRepeatTable.repTime, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repTime)));
                noticeMap.put(CLRepeatTable.repRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingDesc)));
                noticeMap.put(CLRepeatTable.repRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingCode)));
                noticeMap.put(CLRepeatTable.repUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateTime)));
                noticeMap.put(CLRepeatTable.repOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repOpenState)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserName,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserName)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserId)));
                noticeMap.put(CLRepeatTable.repDateOne, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateOne)));
                noticeMap.put(CLRepeatTable.repDateTwo, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateTwo)));
                noticeMap.put(CLRepeatTable.repStateOne, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateOne)));
                noticeMap.put(CLRepeatTable.repStateTwo, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateTwo)));
                noticeMap.put(CLRepeatTable.repAType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repAType)));
                noticeMap.put(CLRepeatTable.repWebURL, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repWebURL)));
                noticeMap.put(CLRepeatTable.repImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repImagePath)));
                noticeMap.put(CLRepeatTable.repInSTable, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repInSTable)));
                noticeMap.put(CLRepeatTable.repEndState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repEndState)));
                noticeMap.put(CLRepeatTable.parReamrk, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.parReamrk)));
                noticeMap.put(CLRepeatTable.repRead, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repRead)));
                noticeMap.put(CLRepeatTable.repPostState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repPostState)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap.put(CLRepeatTable.dataType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataType)));
                noticeMap.put(CLRepeatTable.dataId, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataId)));
                noticeMap.put(CLRepeatTable.remark1, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark1)));
                noticeMap.put(CLRepeatTable.remark2, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark2)));
                noticeMap.put(CLRepeatTable.remark3, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark3)));
                noticeMap.put(CLRepeatTable.remark4, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark4)));
                noticeMap.put(CLRepeatTable.remark5, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark5)));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }


    /**
     * 查询重复母记事
     */
    public List<Map<String, String>> QueryAllChongFuData(int type) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "";
        switch (type) {
            case 0:
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repRead + " = " + 1 + " and "
                        + CLRepeatTable.repUpdateState + " != " + 3
                        + " order by repTime asc";
                break;
            case 1:
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != " + 3
                        + " order by repTime asc";
                break;
            case 2://updatestate不为0，-1的都上传
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != " + 0 + " and "
                        + CLRepeatTable.repUpdateState + " != " + -1
                        + " order by repInitialCreatedTime desc,repTime asc";
                break;
            case 3:// 刚进入程序查询母记事，未删除，未暂停 update!=3,nextcreatetime<当前时间 查询重复母记事
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                Date date = new Date(System.currentTimeMillis());
                String nowtime = simpleDateFormat.format(date);
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != 3 and "
                        + CLRepeatTable.repIsPuase + " = 0 and "
                        + CLRepeatTable.repInSTable + " = 0 "
                        + " and " + CLRepeatTable.repNextCreatedTime + " < '" + nowtime + "' "
                        + " order by repTime asc";
                break;
            case 4:
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != " + 3 + " and "
                        + CLRepeatTable.repIsPuase + " = " + 0
                        + " order by repTime asc";
                break;
            case 5://查询所有母记事
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where repUpdateState != 3 and repUpdateState != -1 order by repTime asc";
                break;
            case 6://上传重复中删除的数据
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " = " + 3
                        + " order by repInitialCreatedTime desc,repTime asc";
                break;
            case 7:
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != " + 3 + " and "
                        + CLRepeatTable.repIsPuase + " = " + 0
                        + " and repInSTable = 1 order by repTime asc";
                break;
            case 8:
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != " + 3 + " and "
                        + CLRepeatTable.repIsPuase + " = " + 0
                        + " and repType = 5 order by repTime asc";
                break;
            case 9:
                sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                        + CLRepeatTable.repUpdateState + " != " + 3 + " and "
                        + CLRepeatTable.repIsPuase + " = " + 0
                        + " and (repType = 2 or repType = 3 or repType = 4 or repType = 6) order by repTime asc";
                break;
            case -1://查询所有母记事
                sql = "select * from " + CLRepeatTable.CLRepeatTable;
            default:
                break;
        }
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLRepeatTable.repID, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repID)));
                noticeMap.put(CLRepeatTable.repBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repBeforeTime)));
                noticeMap.put(CLRepeatTable.repColorType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repColorType)));
                noticeMap.put(CLRepeatTable.repDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repDisplayTime)));
                noticeMap.put(CLRepeatTable.repType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repType)));
                noticeMap.put(CLRepeatTable.repIsAlarm, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsAlarm)));
                noticeMap.put(CLRepeatTable.repIsPuase, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsPuase)));
                noticeMap.put(CLRepeatTable.repIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repIsImportant)));
                noticeMap.put(CLRepeatTable.repSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceType)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap
                        .put(CLRepeatTable.repTypeParameter,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repTypeParameter)));
                noticeMap
                        .put(CLRepeatTable.repNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repNextCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repLastCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repInitialCreatedTime)));
                noticeMap.put(CLRepeatTable.repStartDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStartDate)));
                noticeMap.put(CLRepeatTable.repContent, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repContent)));
                noticeMap.put(CLRepeatTable.repCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repCreateTime)));
                noticeMap.put(CLRepeatTable.repSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceDesc)));
                noticeMap
                        .put(CLRepeatTable.repSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repSourceDescSpare)));
                noticeMap.put(CLRepeatTable.repTime, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repTime)));
                noticeMap.put(CLRepeatTable.repRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingDesc)));
                noticeMap.put(CLRepeatTable.repRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingCode)));
                noticeMap.put(CLRepeatTable.repUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateTime)));
                noticeMap.put(CLRepeatTable.repOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repOpenState)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserName,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserName)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserId)));
                noticeMap.put(CLRepeatTable.repDateOne, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateOne)));
                noticeMap.put(CLRepeatTable.repDateTwo, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateTwo)));
                noticeMap.put(CLRepeatTable.repStateOne, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateOne)));
                noticeMap.put(CLRepeatTable.repStateTwo, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateTwo)));
                noticeMap.put(CLRepeatTable.repAType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repAType)));
                noticeMap.put(CLRepeatTable.repWebURL, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repWebURL)));
                noticeMap.put(CLRepeatTable.repImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repImagePath)));
                noticeMap.put(CLRepeatTable.repInSTable, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repInSTable)));
                noticeMap.put(CLRepeatTable.repEndState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repEndState)));
                noticeMap.put(CLRepeatTable.parReamrk, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.parReamrk)));
                noticeMap.put(CLRepeatTable.repRead, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repRead)));
                noticeMap.put(CLRepeatTable.repPostState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repPostState)));
                noticeMap.put(CLRepeatTable.dataType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataType)));
                noticeMap.put(CLRepeatTable.dataId, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataId)));
                noticeMap.put(CLRepeatTable.remark1, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark1)));
                noticeMap.put(CLRepeatTable.remark2, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark2)));
                noticeMap.put(CLRepeatTable.remark3, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark3)));
                noticeMap.put(CLRepeatTable.remark4, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark4)));
                noticeMap.put(CLRepeatTable.remark5, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark5)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }


        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if (m2.get(CLRepeatTable.repSourceDesc).isEmpty()) {
                    break;
                }
                if (m1.get(CLRepeatTable.repSourceDesc).equals(m2.get(CLRepeatTable.repSourceDesc))) {
                    if (Integer.valueOf(m1.get(CLRepeatTable.repID)) > Integer.valueOf(m2.get(CLRepeatTable.repID))) {
                        dataList.remove(j);
                        continue;
                    }
                }
            }
        }
        return dataList;
    }

    /**
     * 本地删除，就是修改updateState的状态值
     *
     * @param repId
     */
    public void deleteCLRepeatTableLocalData(String repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int id = Integer.parseInt(repId);
        String sql;
        if (id < 0) {
            sql = "delete from " + CLRepeatTable.CLRepeatTable + " where "
                    + CLRepeatTable.repID + " = " + repId;
        } else {
            sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                    + CLRepeatTable.repUpdateState + " = " + 3 + " , "
                    + CLRepeatTable.repRead + " = " + 0 + " where "
                    + CLRepeatTable.repID + " = " + repId + " and "
                    + CLRepeatTable.repUpdateState + " != " + 3;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改是暂停
     *
     * @return
     */
    @SuppressWarnings("unchecked")
    public void updateCLRepeatTableData(Map<String, String> upMap,
                                        String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + "="
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + "='"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String[] str = updateStr.split(",");
        String updateState = str[0].toString();
        String repIsPuase = str[1].toString();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + updateState + " , " + repIsPuase + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取对应的节假日休息
     *
     * @param date
     * @return
     */
    public int getISNOTHOLIDAY(String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from LocateSolarToLunar where CALENDAR = " + date;

        int list = 0;

        Cursor cursor = sqldb.rawQuery(sql, null);
        try {
            while (cursor.moveToNext()) {
                list = cursor.getInt(cursor.getColumnIndex(LocateSolarToLunar.ISNOTHOLIDAY));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    /**
     * 获取农历以及农历对应的国历时间
     *
     * @param canlendar
     */
    public ArrayList<String> getNongli(String canlendar) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from LocateSolarToLunar where CALENDAR = " + canlendar;

        ArrayList<String> list = new ArrayList<>();

        Cursor cursor = sqldb.rawQuery(sql, null);
        try {
            while (cursor.moveToNext()) {
                String LUNAR_CALENDAR = cursor.getString(cursor.getColumnIndex("LUNAR_CALENDAR"));

                String lun_sql = "select * from LocateSolarToLunar where LUNAR_CALENDAR = " + LUNAR_CALENDAR;
                Cursor cursor_l = sqldb.rawQuery(lun_sql, null);
                try {
                    while (cursor_l.moveToNext()) {
                        String time = cursor_l.getString(cursor.getColumnIndex("CALENDAR"));
                        list.add(time);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;

    }

    /**
     * 修改重复事件
     *
     * @return
     */
    public void updateCLRepeatTableData(int repId, int repBeforeTime,
                                        int repColorType, int repDisplayTime, int repType, int repIsAlarm,
                                        int repIsPuase, int repIsImportant, int repSourceType,
                                        int repUpdateState, String repTypeParameter,
                                        String repNextCreatedTime, String repLastCreatedTime,
                                        String repInitialCreatedTime, String repStartDate,
                                        String repContent, String repCreateTime, String repSourceDesc,
                                        String repSourceDescSpare, String repTime, String repRingDesc,
                                        String repRingCode, String repUpdateTime, int repOpenState,
                                        String repCommendedUserName, int repCommendedUserId,
                                        String repDateOne, String repDateTwo, int repStateOne,
                                        int repStateTwo, int repAType, String repWebURL,
                                        String repImagePath, int repInSTable, int repEndState,
                                        String parReamrk, int repRead, int repPostState) {
        deleteRepeatChildTodayAndbBeforeData(repId);
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = repContent.replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "");
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repBeforeTime + " = ?" + ", "
                + CLRepeatTable.repColorType + " = ?" + ", "
                + CLRepeatTable.repDisplayTime + " = ?" + ", "
                + CLRepeatTable.repType + " = ?" + ", "
                + CLRepeatTable.repIsAlarm + " = ?" + ", "
                + CLRepeatTable.repIsPuase + " = ?" + ", "
                + CLRepeatTable.repIsImportant + " = ?" + ", "
                + CLRepeatTable.repSourceType + " = ?" + ", "
                + CLRepeatTable.repUpdateState + " = ?" + ", "
                + CLRepeatTable.repTypeParameter + " = ?" + ", "
                + CLRepeatTable.repNextCreatedTime + " = ?" + ", "
                + CLRepeatTable.repLastCreatedTime + " = ?" + ", "
                + CLRepeatTable.repInitialCreatedTime + " = ?" + ", "
                + CLRepeatTable.repStartDate + " = ?" + ", "
                + CLRepeatTable.repContent + " = ?" + ", "
                + CLRepeatTable.repCreateTime + " = ?" + ", "
                + CLRepeatTable.repSourceDesc + " = ?" + ", "
                + CLRepeatTable.repSourceDescSpare + " = ?" + ", "
                + CLRepeatTable.repTime + " = ?" + ", "
                + CLRepeatTable.repRingDesc + " = ?" + ", "
                + CLRepeatTable.repRingCode + " = ?" + ", "
                + CLRepeatTable.repUpdateTime + " = ?" + ", "
                + CLRepeatTable.repOpenState + " = ?" + ", "
                + CLRepeatTable.repcommendedUserName + " = ?" + ", "
                + CLRepeatTable.repcommendedUserId + " = ?" + ", "
                + CLRepeatTable.repDateOne + " = ?" + ", "
                + CLRepeatTable.repDateTwo + " = ?" + ", "
                + CLRepeatTable.repStateOne + " = ?" + ", "
                + CLRepeatTable.repStateTwo + " = ?" + ", "
                + CLRepeatTable.repAType + " = ?" + ", "
                + CLRepeatTable.repWebURL + " = ?" + ", "
                + CLRepeatTable.repImagePath + " = ?" + ", "
                + CLRepeatTable.repInSTable + " = ?" + ", "
                + CLRepeatTable.repEndState + " = ?" + ", "
                + CLRepeatTable.parReamrk + " = ?" + ", "
                + CLRepeatTable.repRead + " = ?" + " , "
                + CLRepeatTable.repPostState + " = ?" + " where "
                + CLRepeatTable.repID + " = " + repId;
        Object[] mValue = new Object[]{repBeforeTime, repColorType,
                repDisplayTime, repType, repIsAlarm, repIsPuase,
                repIsImportant, repSourceType, repUpdateState,
                StringUtils.getIsStringEqulesNull(repTypeParameter),
                StringUtils.getIsStringEqulesNull(repNextCreatedTime),
                StringUtils.getIsStringEqulesNull(repLastCreatedTime),
                StringUtils.getIsStringEqulesNull(repInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(repStartDate),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(repCreateTime),
                StringUtils.getIsStringEqulesNull(repSourceDesc),
                StringUtils.getIsStringEqulesNull(repSourceDescSpare),
                StringUtils.getIsStringEqulesNull(repTime),
                StringUtils.getIsStringEqulesNull(repRingDesc),
                StringUtils.getIsStringEqulesNull(repRingCode),
                StringUtils.getIsStringEqulesNull(repUpdateTime), repOpenState,
                StringUtils.getIsStringEqulesNull(repCommendedUserName),
                repCommendedUserId,
                StringUtils.getIsStringEqulesNull(repDateOne),
                StringUtils.getIsStringEqulesNull(repDateTwo), repStateOne,
                repStateTwo, repAType,
                StringUtils.getIsStringEqulesNull(repWebURL),
                StringUtils.getIsStringEqulesNull(repImagePath), repInSTable,
                repEndState, StringUtils.getIsStringEqulesNull(parReamrk),
                repRead, repPostState};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改重复母记事时删除日程中当前以及以后的所有子记事
     *
     * @param repId 重复ID
     */
    public void deleteRepeatChildTodayAndbBeforeData(int repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from ScheduleTable where schDate >= " + DateUtil.nowTodyTime() + " and " +
                "schRepeatID = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改重复子记事状态
     */
    public void updateChildSchState(int repId, int important) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schIsImportant + " = " + important + " where "
                + ScheduleTable.schRepeatID + " = " + repId + " and "
                + ScheduleTable.schRepeatLink + " != " + 0 + " and "
                + ScheduleTable.schRepeatLink + " != " + 2;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改重复子记事状态
     */
    public void updateChildSchState(int repId, int important, String schid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schIsImportant + " = " + important + " where "
                + ScheduleTable.schRepeatID + " = " + repId + " and "
                + ScheduleTable.schRepeatLink + " != " + 0 + " and "
                + ScheduleTable.schRepeatLink + " != " + 2 + " and "
                + ScheduleTable.schID + " = " + schid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 插入下载的农历
     */
    public boolean insertNongLiData(int id, String calendar, String solarTerms,
                                    String week, String lunarCalendar, String holiday,
                                    String lunarHoliday, String createTime, String isNotHoliday) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
//        int id = getLocalId(1, "LocateSolarToLunar", LocateSolarToLunar.ID);
        String sql = "replace into LocateSolarToLunar(ID,CALENDAR,SOLAR_TERMS,WEEK,LUNAR_CALENDAR,HOLIDAY,LUNAR_HOLIDAY,CREATE_TIME,ISNOTHOLIDAY) "
                + "values(?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{id,
                StringUtils.getIsStringEqulesNull(calendar),
                StringUtils.getIsStringEqulesNull(solarTerms),
                StringUtils.getIsStringEqulesNull(week),
                StringUtils.getIsStringEqulesNull(lunarCalendar),
                StringUtils.getIsStringEqulesNull(holiday),
                StringUtils.getIsStringEqulesNull(lunarHoliday),
                StringUtils.getIsStringEqulesNull(createTime),
                StringUtils.getIsStringEqulesNull(isNotHoliday)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public String queryISNOTHOLIDAY(String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String ISNOTHOLIDAY = "0";
        String sql = "select * from LocateSolarToLunar where CALENDAR = '" + date + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                ISNOTHOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.ISNOTHOLIDAY));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ISNOTHOLIDAY;
    }

    public String queryLUNAR_HOLIDAY(String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String LUNAR_HOLIDAY = "";
        String sql = "select * from LocateSolarToLunar where CALENDAR = '" + date + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                LUNAR_HOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.LUNAR_HOLIDAY));
                if (LUNAR_HOLIDAY.isEmpty()) {
                    LUNAR_HOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.SOLAR_TERMS));
                }
                if (LUNAR_HOLIDAY.isEmpty()) {
                    LUNAR_HOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.HOLIDAY));
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return LUNAR_HOLIDAY;
    }

    public List<Map<String, String>> queryNOTHOLIDAYs() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> CALENDARs = new ArrayList<>();
        String sql = "select * from LocateSolarToLunar";
        String LUNAR_HOLIDAY;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                Map<String, String> map = new HashMap<>();
                LUNAR_HOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.LUNAR_HOLIDAY));
                if (LUNAR_HOLIDAY.isEmpty()) {
                    LUNAR_HOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.SOLAR_TERMS));
                }
                if (LUNAR_HOLIDAY.isEmpty()) {
                    LUNAR_HOLIDAY = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.HOLIDAY));
                }
                String CALENDAR = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.CALENDAR));

                map.put("LUNAR_HOLIDAY", LUNAR_HOLIDAY);
                map.put("calender", CALENDAR);
                CALENDARs.add(map);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CALENDARs;
    }

    //
    public List<Map<String, String>> queryNOTHOLIDAY(String date, int ISNOTHOLIDAY) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> CALENDARs = new ArrayList<>();
        String sql = "select * from LocateSolarToLunar where CALENDAR >= '" + date + "' and ISNOTHOLIDAY != " + ISNOTHOLIDAY + " limit 50";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                Map<String, String> map = new HashMap<>();
                String CALENDAR = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.CALENDAR));
                String WEEK = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.WEEK));
                String ISNOTHOLIDA = cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.ISNOTHOLIDAY));

                map.put("calender", CALENDAR);
                map.put("week", WEEK);
                map.put("isno", ISNOTHOLIDA);
                CALENDARs.add(map);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return CALENDARs;
    }


    public int queryCLAdsTableJifen(String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int adsScore = 1;
        String sql = "select adsScore from CLAdsTable where adsDate = '" + date + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                adsScore = cursor.getInt(cursor.getColumnIndex(CLAdsTable.adsScore));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return adsScore;
    }

    public List<Map<String, String>> queryMaxDate() {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        Calendar calendar = Calendar.getInstance();
        String sql = "select * from LocateSolarToLunar order by CALENDAR desc";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put("calendar", cursor.getString(cursor
                        .getColumnIndex(LocateSolarToLunar.CALENDAR)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;

    }

    /**
     * 清空农历表的所有数据
     */
    public void deletenongliData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from LocateSolarToLunar";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 农历查公历 type 1是农历查询。，0是阳历
     *
     * @return
     */
    public Map<String, String> queryLunartoSolarList(String monthDay, int type) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String nowDate = DateTimeHelper.formatDateTimetoString(new Date(), DateTimeHelper.FMT_yyyyMMdd);
        Map<String, String> sMap = new HashMap<String, String>();
        String sql = "";
        if (type == 0) {
            sql = "select * from LocateSolarToLunar where CALENDAR ='"
                    + monthDay + "' order by CALENDAR asc";
        } else if (type == 1) {
            sql = "select * from LocateSolarToLunar where LUNAR_CALENDAR ='"
                    + monthDay + "' and CALENDAR " + " >= '" + nowDate
                    + "' order by CALENDAR asc";
        }

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (cursor.getCount() > 0) {
                if (cursor.moveToNext()) {
                    sMap.put("calendar", cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.CALENDAR)));
                    sMap.put("lunarCalendar", cursor.getString(cursor.getColumnIndex(LocateSolarToLunar.LUNAR_CALENDAR)));

                    return sMap;
                }
            } else {
                CalendarChangeValue changeValue = new CalendarChangeValue();
                if (changeValue.changaSZ(monthDay).length() == 2) {
                    sMap.put("calendar", nowDate.substring(0, 7) + "-"
                            + monthDay);
                } else {
                    if (monthDay.length() == 10) {
                        sMap.put("calendar", nowDate.substring(0, 4) + "-"
                                + monthDay.substring(5));
                        sMap.put("lunarCalendar",
                                changeValue.changNL(monthDay.substring(5)));
                    } else {
                        sMap.put("calendar", nowDate.substring(0, 4) + "-"
                                + monthDay);
                        sMap.put("lunarCalendar", changeValue.changNL(monthDay));
                    }
                }

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return sMap;

    }

    /**
     * 根据农历查询最近的阳历
     *
     * @param monthDay
     * @return
     */
    public List<Map<String, String>> queryNearLunartoSolarList(String monthDay) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String nowDate = DateTimeHelper.formatDateTimetoString(new Date(), DateTimeHelper.FMT_yyyyMMdd);
        String year = nowDate.substring(0, 4);
        String yearDate = Integer.parseInt(year) + "-" + nowDate.substring(5);
        String foreverDate = Integer.parseInt(year) + 1 + "-" + nowDate.substring(5);
        List<Map<String, String>> maps = new ArrayList<Map<String, String>>();//二月十七

        String sql = "select * from LocateSolarToLunar where LUNAR_CALENDAR ='"
                + monthDay + "' and CALENDAR " + " >= '" + yearDate + "' order by CALENDAR asc";

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                Map<String, String> noticeMap = new HashMap<>();
                noticeMap.put("calendar", cursor.getString(cursor
                        .getColumnIndex(LocateSolarToLunar.CALENDAR)));
                noticeMap.put("lunarCalendar", cursor.getString(cursor
                        .getColumnIndex(LocateSolarToLunar.LUNAR_CALENDAR)));
                maps.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return maps;
    }

    /**
     * 修改重复ID
     */
    public void UpdateRepeatID(Integer repID, Integer newRepID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repID + " = " + newRepID + " where "
                + CLRepeatTable.repID + " = " + repID;
//        String sql1 = "update " + ScheduleTable.ScheduleTable + " set "
//                + ScheduleTable.schRepeatID + " = " + newRepID + " where "
//                + ScheduleTable.schRepeatID + " = " + repID;
        try {
            sqldb.execSQL(sql);
//            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 和网上同步成功后修改状态值为1
     */
    public void updateRepUpdateState(Integer repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repUpdateState + " = " + 0 + " where "
                + CLRepeatTable.repID + " = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 和网上同步失败后修改状态值为-1
     */
    public void updateRepUpdateStateFaild(Integer repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repUpdateState + " = " + -1 + " where "
                + CLRepeatTable.repID + " = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 和网上同步删除
     */
    public void deleteRepeatData(String repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + CLRepeatTable.CLRepeatTable + " where "
                + CLRepeatTable.repID + " = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 网上下载重复数据插入
     */
    public boolean insertDownCLRepeatTableData(int repId, int repBeforeTime,
                                               int repColorType, int repDisplayTime, int repType, int repIsAlarm,
                                               int repIsPuase, int repIsImportant, int repSourceType,
                                               int repUpdateState, String repTypeParameter,
                                               String repNextCreatedTime, String repLastCreatedTime,
                                               String repInitialCreatedTime, String repStartDate,
                                               String repContent, String repCreateTime, String repSourceDesc,
                                               String repSourceDescSpare, String repTime, String repRingDesc,
                                               String repRingCode, String repUpdateTime, int repOpenState,
                                               String repCommendedUserName, int repCommendedUserId,
                                               String repDateOne, String repDateTwo, int repStateOne,
                                               int repStateTwo, int repAType, String repWebURL,
                                               String repImagePath, int repInSTable, int repEndState,
                                               String parReamrk, int repRead, int repPostState, String dataType, String dataId, String remark1
            , String remark2, String remark3, String remark4, String remark5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "replace into CLRepeatTable(repID,repBeforeTime, repColorType,repDisplayTime,"
                + "repType,repIsAlarm,repIsPuase,repIsImportant,repSourceType,repUpdateState,"
                + "repTypeParameter, repNextCreatedTime,repLastCreatedTime,repInitialCreatedTime,"
                + "repStartDate,repContent, repCreateTime,repSourceDesc, repSourceDescSpare, "
                + "repTime,repRingDesc, repRingCode,repUpdateTime,repOpenState, "
                + "repCommendedUserName,repCommendedUserId, repDateOne, repDateTwo,"
                + "repStateOne,repStateTwo,repAType, repWebURL,repImagePath,repInSTable,"
                + "repEndState,parReamrk,repRead,repPostState,dataType,dataId,remark1,remark2,remark3,remark4,remark5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{repId, repBeforeTime, repColorType,
                repDisplayTime, repType, repIsAlarm, repIsPuase,
                repIsImportant, repSourceType, repUpdateState,
                StringUtils.getIsStringEqulesNull(repTypeParameter),
                StringUtils.getIsStringEqulesNull(repNextCreatedTime),
                StringUtils.getIsStringEqulesNull(repLastCreatedTime),
                StringUtils.getIsStringEqulesNull(repInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(repStartDate),
                StringUtils.getIsStringEqulesNull(repContent),
                StringUtils.getIsStringEqulesNull(repCreateTime),
                StringUtils.getIsStringEqulesNull(repSourceDesc),
                StringUtils.getIsStringEqulesNull(repSourceDescSpare),
                StringUtils.getIsStringEqulesNull(repTime),
                StringUtils.getIsStringEqulesNull(repRingDesc),
                StringUtils.getIsStringEqulesNull(repRingCode),
                StringUtils.getIsStringEqulesNull(repUpdateTime), repOpenState,
                StringUtils.getIsStringEqulesNull(repCommendedUserName),
                repCommendedUserId,
                StringUtils.getIsStringEqulesNull(repDateOne),
                StringUtils.getIsStringEqulesNull(repDateTwo), repStateOne,
                repStateTwo, repAType,
                StringUtils.getIsStringEqulesNull(repWebURL),
                StringUtils.getIsStringEqulesNull(repImagePath), repInSTable,
                repEndState, StringUtils.getIsStringEqulesNull(parReamrk),
                repRead, repPostState, dataType == null ? "0" : dataType,
                StringUtils.getIsStringEqulesNull(dataId),
                StringUtils.getIsStringEqulesNull(remark1),
                StringUtils.getIsStringEqulesNull(remark2),
                StringUtils.getIsStringEqulesNull(remark3),
                StringUtils.getIsStringEqulesNull(remark4),
                StringUtils.getIsStringEqulesNull(remark5)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public void updateRepeatStats(int repId, int repUpdateState) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repUpdateState + " = " + repUpdateState + " where "
                + CLRepeatTable.repID + " = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateAllRepeatIsRead() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLRepeatTable set repRead = 0";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public void updateRepeatIsRead(String repId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLRepeatTable set repRead = 0 where repID = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改重复母记事下一次生成子记事的时间
     *
     * @param repid
     * @param nextdate
     */
    public void updateRepeatTimeNextDate(String repid, String nextdate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repNextCreatedTime + " = '" + nextdate + "' , repEndState = 3 where "
                + CLRepeatTable.repID + " = " + repid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateRepeatremark2(String repid, String remark2) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.remark2 + " = '" + remark2 + "' where "
                + CLRepeatTable.repID + " = " + repid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除对应的未结束子记事
     *
     * @param repid
     */
    public void deleteChildSchIsNoEnd(String repid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schRepeatID + " = " + repid + " and "
                + ScheduleTable.schRepeatLink + " = " + 1 + " or "
                + ScheduleTable.schRepeatLink + " = " + 3 + " and "
                + ScheduleTable.schIsEnd + " != 1";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除对应的子记事
     *
     * @param repid
     */
    public void deleteChildSch(String repid) {
        if (!repid.equals("0")) {
            SQLiteDatabase sqldb = helper.getWritableDatabase();
            String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                    + ScheduleTable.schRepeatID + " = " + repid;
            try {
                sqldb.execSQL(sql);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 删除对应的最新的子记事
     *
     * @param schID
     */
    public void deleteChildSchNew(String schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schID + " = " + schID + " and ("
                + ScheduleTable.schRepeatLink + " = " + 1 + " or "
                + ScheduleTable.schRepeatLink + " = " + 3 + ") and schDate >= '" + DateUtil.nowTodyTime() + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除全部的重复子记事
     *
     * @param
     */
    public void deleteRepeatChildSch() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schRepeatID + " != 0 and "
                + ScheduleTable.schRepeatLink + " = " + 1 + " or "
                + ScheduleTable.schRepeatLink + " = " + 3;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改子记事重复id
     */
    public void UpdateSchrepID(Integer repID, Integer newid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schRepeatID + " = " + newid + " where "
                + ScheduleTable.schRepeatID + " = " + repID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 在子日程中修改重复母记事
     *
     * @return
     */
    public void updateSchCLRepeatData(int repId, String repDateOne,
                                      String repDateTwo, int repStateOne, int repStateTwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repUpdateState + " = " + 2 + " , "
                + CLRepeatTable.repDateOne + " = '" + repDateOne + "', "
                + CLRepeatTable.repDateTwo + " = '" + repDateTwo + "', "
                + CLRepeatTable.repStateOne + " = " + repStateOne + ", "
                + CLRepeatTable.repStateTwo + " = " + repStateTwo + " "
                + " where " + CLRepeatTable.repID + " = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 查询上一条和下一条的状态
     */
    public Map<String, String> QueryStateData(int repid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                + CLRepeatTable.repUpdateState + " != " + 3 + " and "
                + CLRepeatTable.repIsPuase + " != " + 1 + " and "
                + CLRepeatTable.repID + " = " + repid + " order by repTime asc";
        // + " and "+ "repNextCreatedTime" + " <'"
        // + DateUtil.formatDateTime(new Date())
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLRepeatTable.repID, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repID)));
                noticeMap.put(CLRepeatTable.repBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repBeforeTime)));
                noticeMap.put(CLRepeatTable.repColorType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repColorType)));
                noticeMap.put(CLRepeatTable.repDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repDisplayTime)));
                noticeMap.put(CLRepeatTable.repType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repType)));
                noticeMap.put(CLRepeatTable.repIsAlarm, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsAlarm)));
                noticeMap.put(CLRepeatTable.repIsPuase, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsPuase)));
                noticeMap.put(CLRepeatTable.repIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repIsImportant)));
                noticeMap.put(CLRepeatTable.repSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceType)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap
                        .put(CLRepeatTable.repTypeParameter,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repTypeParameter)));
                noticeMap
                        .put(CLRepeatTable.repNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repNextCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repLastCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repInitialCreatedTime)));
                noticeMap.put(CLRepeatTable.repStartDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStartDate)));
                noticeMap.put(CLRepeatTable.repContent, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repContent)));
                noticeMap.put(CLRepeatTable.repCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repCreateTime)));
                noticeMap.put(CLRepeatTable.repSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceDesc)));
                noticeMap
                        .put(CLRepeatTable.repSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repSourceDescSpare)));
                noticeMap.put(CLRepeatTable.repTime, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repTime)));
                noticeMap.put(CLRepeatTable.repRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingDesc)));
                noticeMap.put(CLRepeatTable.repRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingCode)));
                noticeMap.put(CLRepeatTable.repUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateTime)));
                noticeMap.put(CLRepeatTable.repOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repOpenState)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserName,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserName)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserId)));
                noticeMap.put(CLRepeatTable.repDateOne, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateOne)));
                noticeMap.put(CLRepeatTable.repDateTwo, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateTwo)));
                noticeMap.put(CLRepeatTable.repStateOne, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateOne)));
                noticeMap.put(CLRepeatTable.repStateTwo, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateTwo)));
                noticeMap.put(CLRepeatTable.repAType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repAType)));
                noticeMap.put(CLRepeatTable.repWebURL, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repWebURL)));
                noticeMap.put(CLRepeatTable.repImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repImagePath)));
                noticeMap.put(CLRepeatTable.repInSTable, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repInSTable)));
                noticeMap.put(CLRepeatTable.repEndState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repEndState)));
                noticeMap.put(CLRepeatTable.parReamrk, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.parReamrk)));
                noticeMap.put(CLRepeatTable.repRead, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repRead)));
                noticeMap.put(CLRepeatTable.repPostState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repPostState)));
                noticeMap.put(CLRepeatTable.dataType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataType)));
                noticeMap.put(CLRepeatTable.dataId, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataId)));
                noticeMap.put(CLRepeatTable.remark1, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark1)));
                noticeMap.put(CLRepeatTable.remark2, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark2)));
                noticeMap.put(CLRepeatTable.remark3, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark3)));
                noticeMap.put(CLRepeatTable.remark4, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark4)));
                noticeMap.put(CLRepeatTable.remark5, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark5)));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    /**
     * 查询数据库是否有相同id的数据
     */
    public int CheckCountRepData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + CLRepeatTable.CLRepeatTable
                + " where " + CLRepeatTable.repID + " = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    // ==============================好友数据表操作==================================================//
    public boolean insertMFMessageData(Integer fmID, Integer fmSendID,
                                       Integer fmGetID, Integer fmIsAlarm, Integer fmOpenState,
                                       Integer fmPostpone, Integer fmColorType, Integer fmDisplayTime,
                                       Integer fmBeforeTime, Integer fmSourceType, Integer fmType,
                                       String fmParameter, String fmContent, String fmCreateTime,
                                       String fmDate, String fmTime, String fmSourceDesc,
                                       String fmSourceDescSpare, String fmTags, String fmRingDesc,
                                       String fmRingCode, String fmStartDate, String fmInitialCreatedTime,
                                       String fmLastCreatedTime, String fmNextCreatedTime,
                                       Integer fmStatus, Integer fmAType, String fmWebURL,
                                       String fmImagePath, int fmInSTable) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "insert into FMessages values(" + fmID + "," + fmSendID
                + "," + fmGetID + "," + fmIsAlarm + "," + fmOpenState + ","
                + fmPostpone + "," + fmColorType + "," + fmDisplayTime + ","
                + fmBeforeTime + "," + fmSourceType + "," + fmType + ",'"
                + fmParameter + "','" + fmContent + "','" + fmCreateTime
                + "','" + fmDate + "','" + fmTime + "','" + fmSourceDesc
                + "','" + fmSourceDescSpare + "','" + fmTags + "','"
                + fmRingDesc + "','" + fmRingCode + "','" + fmStartDate + "','"
                + fmInitialCreatedTime + "','" + fmLastCreatedTime + "','"
                + fmNextCreatedTime + "' , " + fmStatus + "," + fmAType + ",'"
                + fmWebURL + "','" + fmImagePath + "'," + fmInSTable + ")";
        try {
            sqldb.execSQL(sql);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 查询聊天记录
     *
     * @return
     */
    public List<Map<String, String>> QueryAllLiaoTianData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + FMessages.FMessages + " where "
                + FMessages.fmID + " > " + 0 + " and (" + FMessages.fmSendID
                + " = " + id + " or " + FMessages.fmGetID + " = " + id
                + ") order by fmCreateTime desc";// fmDate asc,fmTime asc,limit
        // + ((pageIndex - 1) * 40) + " , " +40
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(FMessages.fmID, cursor.getString(cursor
                                .getColumnIndex(FMessages.fmID)));
                noticeMap.put(FMessages.fmSendID, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmSendID)));
                noticeMap.put(FMessages.fmGetID, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmGetID)));
                noticeMap.put(FMessages.fmIsAlarm, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmIsAlarm)));
                noticeMap.put(FMessages.fmOpenState, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmOpenState)));
                noticeMap.put(FMessages.fmPostpone, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmPostpone)));
                noticeMap.put(FMessages.fmColorType, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmColorType)));
                noticeMap.put(FMessages.fmDisplayTime, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmDisplayTime)));
                noticeMap.put(FMessages.fmBeforeTime, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmBeforeTime)));
                noticeMap.put(FMessages.fmSourceType, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmSourceType)));
                noticeMap.put(FMessages.fmType, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmType)));
                noticeMap.put(FMessages.fmStatus, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmStatus)));
                noticeMap.put(FMessages.fmParameter, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmParameter)));
                noticeMap.put(FMessages.fmContent, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmContent)));
                noticeMap.put(FMessages.fmCreateTime, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmCreateTime)));
                noticeMap.put(FMessages.fmDate, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmDate)));
                noticeMap.put(FMessages.fmTime, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmTime)));
                noticeMap.put(FMessages.fmSourceDesc, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmSourceDesc)));
                noticeMap.put(FMessages.fmSourceDescSpare, cursor
                        .getString(cursor
                                .getColumnIndex(FMessages.fmSourceDescSpare)));
                noticeMap.put(FMessages.fmTags, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmTags)));
                noticeMap.put(FMessages.fmRingDesc, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmRingDesc)));
                noticeMap.put(FMessages.fmRingCode, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmRingCode)));
                noticeMap.put(FMessages.fmStartDate, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmStartDate)));
                noticeMap
                        .put(FMessages.fmInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(FMessages.fmInitialCreatedTime)));
                noticeMap.put(FMessages.fmLastCreatedTime, cursor
                        .getString(cursor
                                .getColumnIndex(FMessages.fmLastCreatedTime)));
                noticeMap.put(FMessages.fmNextCreatedTime, cursor
                        .getString(cursor
                                .getColumnIndex(FMessages.fmNextCreatedTime)));
                noticeMap.put(FMessages.fmAType, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmAType)));
                noticeMap.put(FMessages.fmWebURL, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmWebURL)));
                noticeMap.put(FMessages.fmImagePath, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmImagePath)));
                noticeMap.put(FMessages.fmInSTable, cursor.getString(cursor
                        .getColumnIndex(FMessages.fmInSTable)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    // 插入发送的消息
    public boolean insertMFMessageSendData(Integer fmSendID, Integer fmGetID,
                                           Integer fmIsAlarm, Integer fmOpenState, Integer fmPostpone,
                                           Integer fmColorType, Integer fmDisplayTime, Integer fmBeforeTime,
                                           Integer fmSourceType, Integer fmType, String fmParameter,
                                           String fmContent, String fmCreateTime, String fmDate,
                                           String fmTime, String fmSourceDesc, String fmSourceDescSpare,
                                           String fmTags, String fmRingDesc, String fmRingCode,
                                           String fmStartDate, String fmInitialCreatedTime,
                                           String fmLastCreatedTime, String fmNextCreatedTime,
                                           Integer fmStatus, Integer fmAType, String fmWebURL,
                                           String fmImagePath, int fmInSTable) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int fmID = getLocalId(-1, "FMessages", FMessages.fmID);
        String sql = "insert into FMessages values(" + fmID + "," + fmSendID
                + "," + fmGetID + "," + fmIsAlarm + "," + fmOpenState + ","
                + fmPostpone + "," + fmColorType + "," + fmDisplayTime + ","
                + fmBeforeTime + "," + fmSourceType + "," + fmType + ",'"
                + fmParameter + "','" + fmContent + "','" + fmCreateTime
                + "','" + fmDate + "','" + fmTime + "','" + fmSourceDesc
                + "','" + fmSourceDescSpare + "','" + fmTags + "','"
                + fmRingDesc + "','" + fmRingCode + "','" + fmStartDate + "','"
                + fmInitialCreatedTime + "','" + fmLastCreatedTime + "','"
                + fmNextCreatedTime + "' , " + fmStatus + "," + fmAType + ",'"
                + fmWebURL + "','" + fmImagePath + "'," + fmInSTable + ")";
        try {
            sqldb.execSQL(sql);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 发送成功，修改消息ID
     */
    public void updateMFMessageSendData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + FMessages.FMessages + " set " + FMessages.fmID
                + " = " + id + " where " + FMessages.fmID + " < " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 发送失败，删除保存消息id为负的
     */
    public void deleteMFMessageSendData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + FMessages.FMessages + " where "
                + FMessages.fmID + " < " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteLiaoTianData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + FMessages.FMessages + " where "
                + FMessages.fmID + " = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 重复下载生成子记事查询母记事
     *
     * @return
     */
    public List<Map<String, String>> QueryDownChongFiData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + CLRepeatTable.CLRepeatTable + " where "
                + CLRepeatTable.repID + " = " + id
                + " order by repInitialCreatedTime desc,repTime asc";// fmDate
        // asc,fmTime
        // asc,
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLRepeatTable.repID, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repID)));
                noticeMap.put(CLRepeatTable.repBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repBeforeTime)));
                noticeMap.put(CLRepeatTable.repColorType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repColorType)));
                noticeMap.put(CLRepeatTable.repDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repDisplayTime)));
                noticeMap.put(CLRepeatTable.repType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repType)));
                noticeMap.put(CLRepeatTable.repIsAlarm, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsAlarm)));
                noticeMap.put(CLRepeatTable.repIsPuase, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repIsPuase)));
                noticeMap.put(CLRepeatTable.repIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repIsImportant)));
                noticeMap.put(CLRepeatTable.repSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceType)));
                noticeMap.put(CLRepeatTable.repUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateState)));
                noticeMap
                        .put(CLRepeatTable.repTypeParameter,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repTypeParameter)));
                noticeMap
                        .put(CLRepeatTable.repNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repNextCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repLastCreatedTime)));
                noticeMap
                        .put(CLRepeatTable.repInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repInitialCreatedTime)));
                noticeMap.put(CLRepeatTable.repStartDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStartDate)));
                noticeMap.put(CLRepeatTable.repContent, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repContent)));
                noticeMap.put(CLRepeatTable.repCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repCreateTime)));
                noticeMap.put(CLRepeatTable.repSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repSourceDesc)));
                noticeMap
                        .put(CLRepeatTable.repSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repSourceDescSpare)));
                noticeMap.put(CLRepeatTable.repTime, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repTime)));
                noticeMap.put(CLRepeatTable.repRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingDesc)));
                noticeMap.put(CLRepeatTable.repRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repRingCode)));
                noticeMap.put(CLRepeatTable.repUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repUpdateTime)));
                noticeMap.put(CLRepeatTable.repOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repOpenState)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserName,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserName)));
                noticeMap
                        .put(CLRepeatTable.repcommendedUserId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLRepeatTable.repcommendedUserId)));
                noticeMap.put(CLRepeatTable.repDateOne, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateOne)));
                noticeMap.put(CLRepeatTable.repDateTwo, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repDateTwo)));
                noticeMap.put(CLRepeatTable.repStateOne, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateOne)));
                noticeMap.put(CLRepeatTable.repStateTwo, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repStateTwo)));
                noticeMap.put(CLRepeatTable.repAType, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repAType)));
                noticeMap.put(CLRepeatTable.repWebURL, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repWebURL)));
                noticeMap.put(CLRepeatTable.repImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repImagePath)));
                noticeMap.put(CLRepeatTable.repInSTable, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repInSTable)));
                noticeMap.put(CLRepeatTable.repEndState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repEndState)));
                noticeMap.put(CLRepeatTable.parReamrk, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.parReamrk)));
                noticeMap.put(CLRepeatTable.repRead, cursor.getString(cursor
                        .getColumnIndex(CLRepeatTable.repRead)));
                noticeMap.put(CLRepeatTable.repPostState, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.repPostState)));
                noticeMap.put(CLRepeatTable.dataType, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataType)));
                noticeMap.put(CLRepeatTable.dataId, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.dataId)));
                noticeMap.put(CLRepeatTable.remark1, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark1)));
                noticeMap.put(CLRepeatTable.remark2, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark2)));
                noticeMap.put(CLRepeatTable.remark3, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark3)));
                noticeMap.put(CLRepeatTable.remark4, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark4)));
                noticeMap.put(CLRepeatTable.remark5, cursor
                        .getString(cursor
                                .getColumnIndex(CLRepeatTable.remark5)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    /**
     * 好友列表
     */
    // 插入发送的消息
    public boolean insertFriendsData(Integer fId, Integer uId, Integer state,
                                     Integer attentionState, Integer type, String backImage,
                                     String titleImg, String uName, Integer attState, Integer isFrends,
                                     Integer isV) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "insert into FriendsTable(fId,uId,state,attentionState,type,backImage,titleImg,uName,attState,isFrends,isV) "
                + "values(?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{fId, uId, state, attentionState, type,
                StringUtils.getIsStringEqulesNull(backImage),
                StringUtils.getIsStringEqulesNull(titleImg),
                StringUtils.getIsStringEqulesNull(uName), attState, isFrends,
                isV};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 查询好友id是否相同
     */
    /**
     * 查询数据库是否有相同id的数据
     */
    public int CheckFriendsIDData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + FriendsTable.FriendsTable
                + " where " + FriendsTable.fId + " = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 修改好友列表
     */
    public void updateFriendsData(Integer fId, Integer uId, Integer state,
                                  Integer attentionState, Integer type, String backImage,
                                  String titleImg, String uName, Integer attState, Integer isFrends,
                                  Integer isV) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + FriendsTable.FriendsTable + " set "
                + FriendsTable.fId + " = ?" + " , " + FriendsTable.uId + " =?"
                + ", " + FriendsTable.state + " = ?" + ", "
                + FriendsTable.attentionState + " = ?" + ", "
                + FriendsTable.type + " = ?" + ", " + FriendsTable.backImage
                + " = ?" + ", " + FriendsTable.titleImg + " = ?" + ", "
                + FriendsTable.uName + " = ?" + ", " + FriendsTable.attState
                + " = ?" + " , " + FriendsTable.isFrends + " = ?" + " , "
                + FriendsTable.isV + " = ?" + " where " + FriendsTable.fId
                + " = " + fId;
        Object[] mValue = new Object[]{fId, uId, state, attentionState, type,
                StringUtils.getIsStringEqulesNull(backImage),
                StringUtils.getIsStringEqulesNull(titleImg),
                StringUtils.getIsStringEqulesNull(uName), attState, isFrends,
                isV};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询好友列表
     *
     * @return
     */
    public List<Map<String, String>> QueryFriendsData(int userId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + FriendsTable.FriendsTable + " where "
                + FriendsTable.uId + " = " + userId;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(FriendsTable.fId, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.fId)));
                noticeMap.put(FriendsTable.uId, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.uId)));
                noticeMap.put(FriendsTable.state, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.state)));
                noticeMap.put(FriendsTable.attentionState, cursor
                        .getString(cursor
                                .getColumnIndex(FriendsTable.attentionState)));
                noticeMap.put(FriendsTable.type, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.type)));
                noticeMap.put(FriendsTable.backImage, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.backImage)));
                noticeMap.put(FriendsTable.titleImg, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.titleImg)));
                noticeMap.put(FriendsTable.uName, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.uName)));
                noticeMap.put(FriendsTable.attState, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.attState)));
                noticeMap.put(FriendsTable.isFrends, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.isFrends)));
                noticeMap.put(FriendsTable.isV, cursor.getString(cursor
                        .getColumnIndex(FriendsTable.isV)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    /**
     * 取消关注，删除日程表中的关注人日程
     */
    public void deleteFocusSch(String aid, int friendid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schAID + " = " + aid + " and "
                + ScheduleTable.schFriendID + " = " + friendid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询是否有相同的关注日程id
     */
    public int CheckFocusIDData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schAID + " = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 根据aid查询本地日程中focusstate状态
     */
    public Map<String, String> QueryFocusStateData(int Id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> map = new HashMap<String, String>();
        String sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schAID + " = " + Id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                map.put(ScheduleTable.schFocusState, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schFocusState)));
                return map;
            }
            cursor.close();
            // if (cursor.getCount() > 0) {
            // if (cursor.moveToNext()) {
            // map.put(ScheduleTable.schFocusState,
            // cursor.getString(cursor
            // .getColumnIndex(ScheduleTable.schFocusState)));
            // cursor.close();
            // return map;
            // }
            // } else {
            // cursor.close();
            // }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return map;
    }

    /**
     * 修改关注好友的日程
     */
    /**
     * 修改关注日程
     *
     * @return
     */
    public void updateFocusScheduleData(String schContent, String schDate,
                                        String schTime, int schIsAlarm, int schBeforeTime,
                                        int schDisplayTime, int schIsPostpone, int schIsImportant,
                                        int schColorType, int schIsEnd, String schTags, int schSourceType,
                                        String schSourceDesc, String schSourceDescSpare, int schRepeatID,
                                        String schRepeatDate, String schUpdateTime, int schUpdateState,
                                        int schOpenState, int schRepeatLink, String schRingDesc,
                                        String schRingCode, String schcRecommendName, int schRead,
                                        int schAID, int schAType, String schWebURL, String schImagePath,
                                        int schFocusState, int schFriendID, int schcRecommendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update ScheduleTable set " + ScheduleTable.schContent
                + " = ?" + "," + ScheduleTable.schDate + " = ? " + ", "
                + ScheduleTable.schTime + " = ?" + ", "
                + ScheduleTable.schIsAlarm + " = ?" + ", "
                + ScheduleTable.schBeforeTime + " = ?" + ", "
                + ScheduleTable.schDisplayTime + " = ?" + ", "
                + ScheduleTable.schIsPostpone + " = ?" + ", "
                + ScheduleTable.schIsImportant + " = ?" + ", "
                + ScheduleTable.schColorType + " = ?" + ", "
                + ScheduleTable.schIsEnd + " = ?" + ", "
                + ScheduleTable.schTags + " = ?" + ", "
                + ScheduleTable.schSourceType + " = ?" + ", "
                + ScheduleTable.schSourceDesc + " = ?" + ", "
                + ScheduleTable.schSourceDescSpare + " = ?" + ", "
                + ScheduleTable.schRepeatID + " = ?" + ", "
                + ScheduleTable.schRepeatDate + " = ?" + ", "
                + ScheduleTable.schUpdateTime + " = ?" + ", "
                + ScheduleTable.schUpdateState + " = ?" + ", "
                + ScheduleTable.schOpenState + " = ?" + ", "
                + ScheduleTable.schRepeatLink + " = ?" + ", "
                + ScheduleTable.schRingDesc + " = ?" + ", "
                + ScheduleTable.schRingCode + " = ?" + ", "
                + ScheduleTable.schcRecommendName + " = ?" + ", "
                + ScheduleTable.schRead + " = ?" + ", " + ScheduleTable.schAID
                + " = ?" + ", " + ScheduleTable.schAType + " = ?" + ", "
                + ScheduleTable.schWebURL + " = ?" + ", "
                + ScheduleTable.schImagePath + " = ?" + ", "
                + ScheduleTable.schFocusState + " = ?" + ", "
                + ScheduleTable.schFriendID + " = ?" + ", "
                + ScheduleTable.schcRecommendId + " = ? " + " where "
                + ScheduleTable.schAID + " = " + schAID;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(schContent),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void deleteFocusScheduleData(int schAID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from ScheduleTable where schAID = " + schAID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     *
     */
    /**
     * 查询关注日程
     */
    public List<Map<String, String>> QueryFocusSch(int friendid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schFriendID + " = " + friendid + " and "
                + ScheduleTable.schFocusState + " != " + 1
                + " and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));

                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if ((m1.get(ScheduleTable.schSourceType).equals("3") && m2.get(ScheduleTable.schSourceType).equals("3")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("4") && m2.get(ScheduleTable.schSourceType).equals("4")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("5") && m2.get(ScheduleTable.schSourceType).equals("5"))) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc))) {
                        dataList.remove(j);
                        continue;
                    }
                }

                if (m1.get(ScheduleTable.schSourceType).equals("2") && m2.get(ScheduleTable.schSourceType).equals("2")) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc)) && !m1.get(ScheduleTable.schcRecommendName).isEmpty()) {
                        dataList.remove(j - 1);
                        continue;
                    }
                }
            }
        }
        return dataList;
    }

    /************************************ 闹钟 ********************************************/
    /**
     * 日程插入到闹钟表中，重复
     */
    public boolean insertClockData(String alarmResultTime,
                                   String noticeContent, Integer beforTime, String alarmClockTime,
                                   String alarmSoundDesc, String alarmSound, Integer displayAlarm,
                                   Integer postpone, Integer alarmType, Integer schID, Integer repID,
                                   Integer isAlarmClock, Integer isEnd, String alarmTypeParamter,
                                   int stateone, int statetwo, String dateone, String datetwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int alarmId = getLocalId(1, "LocateAllNoticeTable",
                LocateAllNoticeTable.alarmId);
        String sql = "replace into LocateAllNoticeTable(alarmId,alarmResultTime,noticeContent,beforTime,"
                + "alarmClockTime,alarmSoundDesc,alarmSound,displayAlarm,postpone,alarmType,schID,repID,isAlarmClock,"
                + "isEnd,alarmTypeParamter,stateone,statetwo,dateone,datetwo) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{alarmId,
                StringUtils.getIsStringEqulesNull(alarmResultTime),
                StringUtils.getIsStringEqulesNull(noticeContent), beforTime,
                StringUtils.getIsStringEqulesNull(alarmClockTime),
                StringUtils.getIsStringEqulesNull(alarmSoundDesc),
                StringUtils.getIsStringEqulesNull(alarmSound), displayAlarm,
                postpone, alarmType, schID, repID, isAlarmClock, isEnd,
                StringUtils.getIsStringEqulesNull(alarmTypeParamter), stateone,
                statetwo, StringUtils.getIsStringEqulesNull(dateone),
                StringUtils.getIsStringEqulesNull(datetwo)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 每天问候
     *
     * @return
     */
    public boolean insertEveryClockData(Integer alarmId,
                                        String alarmResultTime, String noticeContent, Integer beforTime,
                                        String alarmClockTime, String alarmSoundDesc, String alarmSound,
                                        Integer displayAlarm, Integer postpone, Integer alarmType,
                                        Integer schID, Integer repID, Integer isAlarmClock, Integer isEnd,
                                        String alarmTypeParamter, int stateone, int statetwo,
                                        String dateone, String datetwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "insert into LocateAllNoticeTable(alarmId,alarmResultTime,noticeContent,beforTime,"
                + "alarmClockTime,alarmSoundDesc,alarmSound,displayAlarm,postpone,alarmType,schID,repID,isAlarmClock,"
                + "isEnd,alarmTypeParamter,stateone,statetwo,dateone,datetwo) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{alarmId,
                StringUtils.getIsStringEqulesNull(alarmResultTime),
                StringUtils.getIsStringEqulesNull(noticeContent), beforTime,
                StringUtils.getIsStringEqulesNull(alarmClockTime),
                StringUtils.getIsStringEqulesNull(alarmSoundDesc),
                StringUtils.getIsStringEqulesNull(alarmSound), displayAlarm,
                postpone, alarmType, schID, repID, isAlarmClock, isEnd,
                StringUtils.getIsStringEqulesNull(alarmTypeParamter), stateone,
                statetwo, StringUtils.getIsStringEqulesNull(dateone),
                StringUtils.getIsStringEqulesNull(datetwo)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public void insertEveryClockData2(Integer alarmId,
                                      String alarmResultTime, String noticeContent, Integer beforTime,
                                      String alarmClockTime, String alarmSoundDesc, String alarmSound,
                                      Integer displayAlarm, Integer postpone, Integer alarmType,
                                      Integer schID, Integer repID, Integer isAlarmClock, Integer isEnd,
                                      String alarmTypeParamter, int stateone, int statetwo,
                                      String dateone, String datetwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "replace into LocateAllNoticeTable(alarmId,alarmResultTime,noticeContent,beforTime,"
                + "alarmClockTime,alarmSoundDesc,alarmSound,displayAlarm,postpone,alarmType,schID,repID,isAlarmClock,"
                + "isEnd,alarmTypeParamter,stateone,statetwo,dateone,datetwo) "
                + "values(" + alarmId + ",'" + StringUtils.getIsStringEqulesNull(alarmResultTime) + "','" + StringUtils.getIsStringEqulesNull(noticeContent) + "'" +
                "," + beforTime + ",'" + StringUtils.getIsStringEqulesNull(alarmClockTime) + "','" + StringUtils.getIsStringEqulesNull(alarmSoundDesc) + "'" +
                ",'" + StringUtils.getIsStringEqulesNull(alarmSound) + "'," + displayAlarm + "," +
                "" + postpone + "," + alarmType + "," + schID + "," + repID + "," + isAlarmClock + "," + isEnd + ",'" + StringUtils.getIsStringEqulesNull(alarmTypeParamter) + "'" +
                "," + stateone + "," + statetwo + ",'" + StringUtils.getIsStringEqulesNull(dateone) + "','" + StringUtils.getIsStringEqulesNull(datetwo) + "')";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改日程闹钟表
     */
    public void updateSchClock(String alarmResultTime, String noticeContent,
                               Integer beforTime, String alarmClockTime, String alarmSoundDesc,
                               String alarmSound, Integer displayAlarm, Integer postpone,
                               Integer alarmType, Integer schID, Integer repID,
                               Integer isAlarmClock, Integer isEnd) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.alarmResultTime + " = ?"
                + ", " + LocateAllNoticeTable.noticeContent + " = ?" + ", "
                + LocateAllNoticeTable.beforTime + " = ?" + ", "
                + LocateAllNoticeTable.alarmClockTime + " = ?" + ", "
                + LocateAllNoticeTable.alarmSoundDesc + " = ?" + ", "
                + LocateAllNoticeTable.alarmSound + " = ?" + ", "
                + LocateAllNoticeTable.displayAlarm + " = ?" + ", "
                + LocateAllNoticeTable.postpone + " = ?" + ", "
                + LocateAllNoticeTable.alarmType + " = ?" + ", "
                + LocateAllNoticeTable.schID + " = ?" + ", "
                + LocateAllNoticeTable.repID + " = ?" + ", "
                + LocateAllNoticeTable.isAlarmClock + " = ?" + " , "
                + LocateAllNoticeTable.isEnd + " = ?" + " where "
                + LocateAllNoticeTable.schID + " = " + schID;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(alarmResultTime),
                StringUtils.getIsStringEqulesNull(noticeContent), beforTime,
                StringUtils.getIsStringEqulesNull(alarmClockTime),
                StringUtils.getIsStringEqulesNull(alarmSoundDesc),
                StringUtils.getIsStringEqulesNull(alarmSound), displayAlarm,
                postpone, alarmType, schID, repID, isAlarmClock, isEnd};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改闹钟日程ID
     */
    public void UpdateClockSchID(String SchID, String newid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.schID + " = " + newid
                + " where " + LocateAllNoticeTable.schID + " = " + SchID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改重复闹钟表
     */
    public void updateRepClock(String alarmResultTime, String noticeContent,
                               Integer beforTime, String alarmClockTime, String alarmSoundDesc,
                               String alarmSound, Integer displayAlarm, Integer postpone,
                               Integer alarmType, Integer schID, Integer repID,
                               Integer isAlarmClock, Integer isEnd, String alarmTypeParamter,
                               int stateone, int statetwo, String dateone, String datetwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.alarmResultTime + " = ?"
                + ", " + LocateAllNoticeTable.noticeContent + " = ?" + ", "
                + LocateAllNoticeTable.beforTime + " = ?" + ", "
                + LocateAllNoticeTable.alarmClockTime + " = ?" + ", "
                + LocateAllNoticeTable.alarmSoundDesc + " = ?" + ", "
                + LocateAllNoticeTable.alarmSound + " = ?" + ", "
                + LocateAllNoticeTable.displayAlarm + " = ?" + ", "
                + LocateAllNoticeTable.postpone + " = ?" + ", "
                + LocateAllNoticeTable.alarmType + " = ?" + ", "
                + LocateAllNoticeTable.schID + " = ?" + ", "
                + LocateAllNoticeTable.repID + " = ?" + " , "
                + LocateAllNoticeTable.isAlarmClock + " = ?" + ", "
                + LocateAllNoticeTable.isEnd + " = ?" + ", "
                + LocateAllNoticeTable.alarmTypeParamter + " = ?" + ", "
                + LocateAllNoticeTable.stateone + " = ?" + ", "
                + LocateAllNoticeTable.statetwo + " = ?" + ", "
                + LocateAllNoticeTable.dateone + " = ?" + ", "
                + LocateAllNoticeTable.datetwo + " = ?" + " where "
                + LocateAllNoticeTable.repID + " = " + repID;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(alarmResultTime),
                StringUtils.getIsStringEqulesNull(noticeContent), beforTime,
                StringUtils.getIsStringEqulesNull(alarmClockTime),
                StringUtils.getIsStringEqulesNull(alarmSoundDesc),
                StringUtils.getIsStringEqulesNull(alarmSound), displayAlarm,
                postpone, alarmType, schID, repID, isAlarmClock, isEnd,
                StringUtils.getIsStringEqulesNull(alarmTypeParamter), stateone,
                statetwo, StringUtils.getIsStringEqulesNull(dateone),
                StringUtils.getIsStringEqulesNull(datetwo)};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改闹钟重复ID
     */
    public void UpdateClockRepID(String RepID, String newid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.repID + " = " + newid
                + " where " + LocateAllNoticeTable.repID + " = " + RepID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 删除日程闹钟
     */
    public void deleteSch(int schID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + LocateAllNoticeTable.LocateAllNoticeTable
                + " where " + LocateAllNoticeTable.schID + " = " + schID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 删除重复闹钟
     */
    public void deleteRep(int repID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + LocateAllNoticeTable.LocateAllNoticeTable
                + " where " + LocateAllNoticeTable.repID + " = " + repID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteRep(String repID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + LocateAllNoticeTable.LocateAllNoticeTable
                + " where " + LocateAllNoticeTable.repID + " = " + repID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除每天闹钟提醒
     */
    public void deleteEveryClock(int alarmid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + LocateAllNoticeTable.LocateAllNoticeTable
                + " where " + LocateAllNoticeTable.alarmId + " = " + alarmid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改闹钟日程是否结束
     */
    @SuppressWarnings("unchecked")
    public void updateSchIsEnd(Map<String, String> upMap, String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + "="
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + "='"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String[] str = updateStr.split(",");
        String isEnd = str[0].toString();
        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + isEnd + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     *
     */
    public void updateClockDate(int id, String alarmResultTime,
                                String alarmClockTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.alarmResultTime + " = '"
                + alarmResultTime + "', " + LocateAllNoticeTable.alarmClockTime
                + " = '" + alarmClockTime + "' where "
                + LocateAllNoticeTable.alarmId + " = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 更改日程闹钟提醒时间
     */
    public void updateSchClockDate(int schId, String alarmResultTime,
                                   String alarmClockTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.alarmResultTime + " = '"
                + alarmResultTime + "', " + LocateAllNoticeTable.alarmClockTime
                + " = '" + alarmClockTime + "' where "
                + LocateAllNoticeTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 更改为待办
     */
    public void updateUnTaskClockDate(int schId, String alarmSoundDesc,
                                      String alarmSound) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + LocateAllNoticeTable.LocateAllNoticeTable
                + " set " + LocateAllNoticeTable.beforTime + " = " + 0 + ", "
                + LocateAllNoticeTable.alarmSoundDesc + " = '" + alarmSoundDesc
                + "'," + LocateAllNoticeTable.alarmSound + " = '" + alarmSound
                + "'," + LocateAllNoticeTable.displayAlarm + " = " + 0 + ","
                + LocateAllNoticeTable.postpone + " = " + 1 + ","
                + LocateAllNoticeTable.isAlarmClock + " = " + 1 + ","
                + LocateAllNoticeTable.isEnd + " = " + 0 + " where "
                + LocateAllNoticeTable.schID + " = " + schId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 查询是否有id重复
     *
     * @return
     * @paramid
     */
    public int CheckClockIDData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from "
                + LocateAllNoticeTable.LocateAllNoticeTable + " where "
                + LocateAllNoticeTable.alarmId + " = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 获得闹钟
     *
     * @return List<Map < String, String>>
     */
    public List<Map<String, String>> getAlarmData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = null;
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        dataList.clear();
        // 当前时间
        String currentTimeSs = DateUtil.formatDateTimeSs(new Date());
        String content = "";
        String before = "";
        String sql = "select * from LocateAllNoticeTable where alarmClockTime!='' and displayAlarm=1 and postpone=0 and isEnd=0 and alarmResultTime"//and repID=0
                + " >='" + DateUtil.formatDateTimeSs(new Date()) + "' order by alarmResultTime asc";
//        String newsql = "select * from LocateAllNoticeTable order by alarmResultTime asc";

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);

            while (cursor.moveToNext()) {

                noticeMap = new HashMap<>();
                noticeMap.put(LocateAllNoticeTable.alarmId, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmId)));

                content = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.noticeContent));
                before = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.beforTime));
                noticeMap.put(LocateAllNoticeTable.alarmSoundDesc, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));
                noticeMap.put(LocateAllNoticeTable.alarmSound, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmSound)));
                String aclock = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmClockTime));
                if (aclock.length() == 16) {
                    aclock = DateUtil.formatDateTimeSs(DateUtil.parseDateTime(aclock));
                }
                String alarmResultTime = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmResultTime));
                if (alarmResultTime.length() == 16) {
                    alarmResultTime = DateUtil.formatDateTimeSs(DateUtil.parseDateTime(alarmResultTime));
                }

                noticeMap.put(LocateAllNoticeTable.noticeContent, content);
                noticeMap.put(LocateAllNoticeTable.alarmResultTime, alarmResultTime);

                noticeMap.put(LocateAllNoticeTable.alarmClockTime, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmClockTime)));

                noticeMap.put(LocateAllNoticeTable.beforTime, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.beforTime)));

                noticeMap.put(LocateAllNoticeTable.alarmType, "0");
                noticeMap.put(LocateAllNoticeTable.isAlarmClock, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
                noticeMap.put(LocateAllNoticeTable.displayAlarm, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.displayAlarm)));
                noticeMap.put(LocateAllNoticeTable.postpone, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.postpone)));
                noticeMap.put(LocateAllNoticeTable.stateone, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.stateone)));
                noticeMap.put(LocateAllNoticeTable.statetwo, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.statetwo)));
                noticeMap.put(LocateAllNoticeTable.dateone, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.dateone)));
                noticeMap.put(LocateAllNoticeTable.datetwo, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.datetwo)));
                noticeMap.put(LocateAllNoticeTable.repID, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.repID)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        String nowDate = DateTimeHelper.formatDateTimetoString(new Date(), DateTimeHelper.FMT_yyyyMMdd);
        // 重复闹钟
//        try {
//            String sqlr = "select * from LocateAllNoticeTable where alarmClockTime!='' and displayAlarm=1 and alarmType!=0 and repID!=0 and schID=0 and isEnd=0 "
//                    + " order by alarmResultTime asc";
//            Cursor cursorr = sqldb.rawQuery(sqlr, null);
//            while (cursorr.moveToNext()) {
//                noticeMap = new HashMap<>();
//                int tpDataType = cursorr.getInt(cursorr.getColumnIndex(LocateAllNoticeTable.alarmType));
//                String isAlarmClock = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.isAlarmClock));
//                noticeMap.put(LocateAllNoticeTable.alarmId, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmId)));
//                content = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.noticeContent));
//                before = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.beforTime));
//                noticeMap.put(LocateAllNoticeTable.alarmSoundDesc, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));
//                noticeMap.put(LocateAllNoticeTable.alarmSound, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmSound)));
//                noticeMap.put(LocateAllNoticeTable.alarmClockTime, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime)));
//
//                noticeMap.put(LocateAllNoticeTable.beforTime, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.beforTime)));
//
//                noticeMap.put(LocateAllNoticeTable.alarmType, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmType)));
//                noticeMap.put(LocateAllNoticeTable.isAlarmClock, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
//                noticeMap.put(LocateAllNoticeTable.displayAlarm, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.displayAlarm)));
//                noticeMap.put(LocateAllNoticeTable.postpone, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.postpone)));
//                noticeMap.put(LocateAllNoticeTable.noticeContent, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.noticeContent)));
//                noticeMap.put(LocateAllNoticeTable.stateone, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.stateone)));
//                noticeMap.put(LocateAllNoticeTable.statetwo, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.statetwo)));
//                noticeMap.put(LocateAllNoticeTable.dateone, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.dateone)));
//                noticeMap.put(LocateAllNoticeTable.datetwo, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.datetwo)));
//                noticeMap.put(LocateAllNoticeTable.repID, cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.repID)));
//                String dateone = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.dateone));
//                String datetwo = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.datetwo));
//                if ("null".equals(dateone)) {
//                    dateone = "";
//                }
//                if ("null".equals(datetwo)) {
//                    datetwo = "";
//                }
//                Calendar datecalendar = Calendar.getInstance();
//                if (!"0".equals(before)) {
//                    if (!"".equals(dateone)) {
//                        datecalendar.setTime(DateUtil.parseDateTime(dateone));
//                        datecalendar.add(Calendar.MINUTE, -Integer.parseInt(before));
//                        dateone = DateUtil.formatDateTime(datecalendar.getTime());
//                    }
//                    if (!"".equals(datetwo)) {
//                        datecalendar.setTime(DateUtil.parseDateTime(datetwo));
//                        datecalendar.add(Calendar.MINUTE, -Integer.parseInt(before));
//                        datetwo = DateUtil.formatDateTime(datecalendar.getTime());
//                    }
//                }
//                RepeatBean repeatBean = null;
//                if (tpDataType == 1) {// 每天
//                    String everynoteDate = "";// 记事日期
//                    Calendar cals = Calendar.getInstance();
//                    cals.add(Calendar.DATE, 1);
//                    String tomorrow = DateTimeHelper.formatDateTimetoString(
//                            cals.getTime(), DateTimeHelper.FMT_yyyyMMdd);
//                    String alarmclock = "";
//                    everynoteDate = nowDate;
//
//                    String alarmResultStartTime = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmResultTime));
//
//                    alarmclock = everynoteDate + " " + cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime)).substring(11);
//
//                    repeatBean = RepeatDateUtils.saveCalendar(cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime)).substring(11, 16), 1, "", "");
//                    if ("1".equals(isAlarmClock)) {// 准时有，提前没有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("2".equals(isAlarmClock)) {// 准时没有，提前有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("3".equals(isAlarmClock)) {
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    }
//                    noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    if (!"".equals(dateone) && !"".equals(datetwo)) {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                        if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                    } else {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if ("".equals(dateone) && "".equals(datetwo)) {
//                            dataList.add(noticeMap);
//                        }
//                    }
//                } else if (tpDataType == 2) {// 每周
//                    String alarmResultStartTime = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmResultTime));
//                    String paramter = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmTypeParamter));
//                    repeatBean = RepeatDateUtils.saveCalendar(cursorr.getString(
//                                            cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime)).substring(11, 16), 2, paramter.replace("[", "").replace("]", "").replace("\"", ""), "");
//                    if ("1".equals(isAlarmClock)) {// 准时有，提前没有
//                        // 如果闹钟时间大于当前时间
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("2".equals(isAlarmClock)) {// 准时没有，提前有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("3".equals(isAlarmClock)) {
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    }
//                    if (!"".equals(dateone) && !"".equals(datetwo)) {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                        if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                    } else {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if ("".equals(dateone) && "".equals(datetwo)) {
//                            dataList.add(noticeMap);
//                        }
//                    }
//                } else if (tpDataType == 3) {//每月
//                    String alarmResultStartTime = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmResultTime));
//                    String paramter = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmTypeParamter));
//                    repeatBean = RepeatDateUtils.saveCalendar(cursorr.getString(
//                                            cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime))
//                                            .substring(11, 16), 3, paramter
//                                            .replace("[", "").replace("]", "")
//                                            .replace("\"", ""), "");
//                    if ("1".equals(isAlarmClock)) {// 准时有，提前没有
//                        // 如果闹钟时间大于当前时间
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("2".equals(isAlarmClock)) {// 准时没有，提前有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("3".equals(isAlarmClock)) {
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    }
//                    if (!"".equals(dateone) && !"".equals(datetwo)) {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                        if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                    } else {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if ("".equals(dateone) && "".equals(datetwo)) {
//                            dataList.add(noticeMap);
//                        }
//                    }
//                } else if (tpDataType == 4) {// 每年 阳历
//                    String alarmResultStartTime = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmResultTime));
//                    String paramter = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmTypeParamter));
//                    repeatBean = RepeatDateUtils.saveCalendar(cursorr.getString(
//                                            cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime))
//                                            .substring(11, 16), 4, paramter
//                                            .replace("[", "").replace("]", "")
//                                            .replace("\"", ""), "0");
//                    if ("1".equals(isAlarmClock)) {// 准时有，提前没有
//                        // 如果闹钟时间大于当前时间
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("2".equals(isAlarmClock)) {// 准时没有，提前有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("3".equals(isAlarmClock)) {
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    }
//                    if (!"".equals(dateone) && !"".equals(datetwo)) {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                        if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                    } else {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if ("".equals(dateone) && "".equals(datetwo)) {
//                            dataList.add(noticeMap);
//                        }
//                    }
//                } else if (tpDataType == 5) {// 工作日
//                    String noteDate = "";// 记事日期
//                    Calendar calendar = Calendar.getInstance();
//                    String alarmclocktime = "";
//                    String nowday = DateUtil.formatDate(new Date());
//                    if ("周六".equals(CharacterUtil.getWeekOfDate(mContextApplication, DateUtil.parseDate(nowday)))) {
//                        calendar.add(Calendar.DATE, 2);
//                        noteDate = DateUtil.formatDate(calendar.getTime());
//                    } else if ("周日".equals(CharacterUtil.getWeekOfDate(mContextApplication, DateUtil.parseDate(nowday)))) {
//                        calendar.add(Calendar.DATE, 1);
//                        noteDate = DateUtil.formatDate(calendar.getTime());
//                    } else {
//                        noteDate = nowday;
//                    }
//                    String alarmResultStartTime = noteDate + " " + cursorr.getString(
//                                    cursorr.getColumnIndex(LocateAllNoticeTable.alarmResultTime)).substring(11);
//                    alarmclocktime = noteDate + " " + cursorr.getString(
//                                    cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime)).substring(11);
//
//                    repeatBean = RepeatDateUtils.saveCalendar(cursorr.getString(
//                                    cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime))
//                                            .substring(11, 16), 5, "", "");
//                    if ("1".equals(isAlarmClock)) {// 准时有，提前没有
//                        // 如果闹钟时间大于当前时间
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("2".equals(isAlarmClock)) {// 准时没有，提前有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("3".equals(isAlarmClock)) {
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    }
//                    noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    if (!"".equals(dateone) && !"".equals(datetwo)) {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                        if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                    } else {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if ("".equals(dateone) && "".equals(datetwo)) {
//                            dataList.add(noticeMap);
//                        }
//                    }
//                } else if (tpDataType == 6) {// 每年 阴历
//                    String alarmResultStartTime = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmResultTime));
//                    String paramter = cursorr.getString(cursorr.getColumnIndex(LocateAllNoticeTable.alarmTypeParamter));
//                    repeatBean = RepeatDateUtils.saveCalendar(cursorr.getString(
//                                            cursorr.getColumnIndex(LocateAllNoticeTable.alarmClockTime))
//                                            .substring(11, 16), 4, paramter
//                                            .replace("[", "").replace("]", "")
//                                            .replace("\"", ""), "1");
//                    if ("1".equals(isAlarmClock)) {// 准时有，提前没有
//                        // 如果闹钟时间大于当前时间
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    } else if ("2".equals(isAlarmClock)) {// 准时没有，提前有
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        // if (DateUt
//                    } else if ("3".equals(isAlarmClock)) {
//                        noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                        noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));
//                    }
//                    if (!"".equals(dateone) && !"".equals(datetwo)) {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                        if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        }
//                    } else {
//                        if (!"".equals(dateone)) {
//                            if (dateone.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if (!"".equals(datetwo)) {
//                            if (datetwo.equals(repeatBean.repNextCreatedTime)) {
//
//                            } else {
//                                dataList.add(noticeMap);
//                            }
//                        } else if ("".equals(dateone) && "".equals(datetwo)) {
//                            dataList.add(noticeMap);
//                        }
//                    }
//                }
//            }
//            cursorr.close();
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

        //顺延闹钟
        String sqlPostPone = "select * from LocateAllNoticeTable where displayAlarm=1 and isEnd=0 and repID=0 and alarmClockTime!='' and postpone=1 and alarmId>=0 "
                + " order by alarmResultTime asc";// and alarmResultTime +
        try {

            Cursor cursor = sqldb.rawQuery(sqlPostPone, null);
            while (cursor.moveToNext()) {

                noticeMap = new HashMap<>();

                noticeMap.put(LocateAllNoticeTable.alarmId, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmId)));

                content = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.noticeContent));
                before = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.beforTime));

                noticeMap.put(LocateAllNoticeTable.alarmSoundDesc, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));

                noticeMap.put(LocateAllNoticeTable.alarmSound, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmSound)));
                noticeMap.put(LocateAllNoticeTable.stateone, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.stateone)));
                noticeMap.put(LocateAllNoticeTable.statetwo, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.statetwo)));
                noticeMap.put(LocateAllNoticeTable.dateone, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.dateone)));
                noticeMap.put(LocateAllNoticeTable.datetwo, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.datetwo)));
                String aclock = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.alarmClockTime));
                noticeMap.put(LocateAllNoticeTable.repID, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.repID)));
                if (aclock.length() == 16) {
                    aclock = DateUtil.formatDateTimeSs(DateUtil
                            .parseDateTime(aclock));
                }
                // 计算闹钟最终执行时间
                // String nowDate = DateTimeHelper.formatDateTimetoString(
                // new Date(), DateTimeHelper.FMT_yyyyMMdd);
                String isAlarmClock = cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.isAlarmClock));
                // Calendar cd = Calendar.getInstance();
                // cd.setTime(DateUtil.parseDateTimeSs(nowDate + " "
                // + aclock.substring(11)));

                // cd.add(Calendar.MINUTE, -cursor.getInt(cursor
                // .getColumnIndex(LocateAllNoticeTable.beforTime)));
                // String alarmResultTime =
                // DateTimeHelper.formatDateTimetoString(
                // cd.getTime(), DateTimeHelper.FMT_yyyyMMddHHmmss);
                String alarmResultTime = aclock;
                RepeatBean repeatBean = RepeatDateUtils.saveCalendar(alarmResultTime.substring(11, 16), 1, "", "");
                if (alarmResultTime.length() == 16) {
                    alarmResultTime = DateUtil.formatDateTimeSs(DateUtil.parseDateTime(alarmResultTime));
                }


                noticeMap.put(LocateAllNoticeTable.noticeContent, content);
                noticeMap.put(LocateAllNoticeTable.alarmResultTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));

                noticeMap.put(LocateAllNoticeTable.alarmClockTime, DateUtil.formatDateTimeSs(DateUtil.parseDateTime(repeatBean.repNextCreatedTime)));

                noticeMap.put(LocateAllNoticeTable.beforTime, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.beforTime)));

                noticeMap.put(LocateAllNoticeTable.alarmType, "0");
                noticeMap.put(LocateAllNoticeTable.isAlarmClock, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
                noticeMap.put(LocateAllNoticeTable.displayAlarm, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.displayAlarm)));
                noticeMap.put(LocateAllNoticeTable.postpone, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.postpone)));

                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        //每天早晚提醒闹钟
        String everysql = "select * from LocateAllNoticeTable where displayAlarm=1  and repID=0 and alarmClockTime!='' and postpone=1 and alarmId<0 and alarmId !=-10 "
                + " order by alarmResultTime asc";

        try {

            Cursor cursor = sqldb.rawQuery(everysql, null);
            while (cursor.moveToNext()) {

                noticeMap = new HashMap<String, String>();

                noticeMap.put(LocateAllNoticeTable.alarmId, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.alarmId)));

                noticeMap
                        .put(LocateAllNoticeTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.noticeContent)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSound)));
                noticeMap
                        .put(LocateAllNoticeTable.stateone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.stateone)));
                noticeMap
                        .put(LocateAllNoticeTable.statetwo,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.statetwo)));
                noticeMap.put(LocateAllNoticeTable.dateone, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.dateone)));
                noticeMap.put(LocateAllNoticeTable.datetwo, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.datetwo)));
                String alarmtime = cursor
                        .getString(
                                cursor.getColumnIndex(LocateAllNoticeTable.alarmResultTime))
                        .substring(11);
                if (alarmtime.length() == 5) {
                    alarmtime = alarmtime + ":00";
                }
                Calendar cd = Calendar.getInstance();
                cd.setTime(DateUtil.parseDateTimeSs(nowDate + " " + alarmtime));
                String alarmResultTime = DateTimeHelper.formatDateTimetoString(
                        cd.getTime(), DateTimeHelper.FMT_yyyyMMddHHmmss);
                if (DateUtil.parseDateTimeSs(
                        DateUtil.formatDateTimeSs(cd.getTime())).getTime() > DateUtil
                        .parseDateTimeSs(currentTimeSs).getTime()) {

                } else {
                    Calendar cdx = Calendar.getInstance();
                    cdx.setTime(cd.getTime());
                    cdx.add(cdx.DATE, 1);
                    alarmResultTime = DateTimeHelper.formatDateTimetoString(
                            cdx.getTime(), DateTimeHelper.FMT_yyyyMMddHHmmss);
                }
                noticeMap
                        .put(LocateAllNoticeTable.beforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.beforTime)));

                noticeMap.put(LocateAllNoticeTable.alarmType, "7");
                noticeMap
                        .put(LocateAllNoticeTable.isAlarmClock,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
                noticeMap
                        .put(LocateAllNoticeTable.displayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.displayAlarm)));
                noticeMap
                        .put(LocateAllNoticeTable.postpone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.postpone)));
                noticeMap.put(LocateAllNoticeTable.alarmResultTime,
                        alarmResultTime);

                noticeMap.put(LocateAllNoticeTable.alarmClockTime,
                        alarmResultTime);
                noticeMap.put(LocateAllNoticeTable.repID, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.repID)));
                dataList.add(noticeMap);
            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
        // 每5分钟执行一次
        String mysql = "select * from LocateAllNoticeTable where alarmId=-10 "
                + " order by alarmResultTime asc";

        try {

            Cursor cursor = sqldb.rawQuery(mysql, null);
            while (cursor.moveToNext()) {

                noticeMap = new HashMap<String, String>();

                noticeMap.put(LocateAllNoticeTable.alarmId, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.alarmId)));

                noticeMap
                        .put(LocateAllNoticeTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.noticeContent)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSound)));
                noticeMap
                        .put(LocateAllNoticeTable.stateone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.stateone)));
                noticeMap
                        .put(LocateAllNoticeTable.statetwo,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.statetwo)));
                noticeMap.put(LocateAllNoticeTable.dateone, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.dateone)));
                noticeMap.put(LocateAllNoticeTable.datetwo, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.datetwo)));
                String alarmtime = cursor.getString(cursor
                        .getColumnIndex(LocateAllNoticeTable.alarmResultTime));

                Calendar cd = Calendar.getInstance();
                cd.setTime(DateUtil.parseDateTimeSs(alarmtime));
                String alarmResultTime = DateTimeHelper.formatDateTimetoString(
                        cd.getTime(), DateTimeHelper.FMT_yyyyMMddHHmmss);

                noticeMap.put(LocateAllNoticeTable.alarmResultTime,
                        alarmResultTime);

                noticeMap
                        .put(LocateAllNoticeTable.alarmClockTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmClockTime)));

                noticeMap
                        .put(LocateAllNoticeTable.beforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.beforTime)));

                noticeMap.put(LocateAllNoticeTable.alarmType, "10");
                noticeMap
                        .put(LocateAllNoticeTable.isAlarmClock,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
                noticeMap
                        .put(LocateAllNoticeTable.displayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.displayAlarm)));
                noticeMap
                        .put(LocateAllNoticeTable.postpone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.postpone)));
                noticeMap.put(LocateAllNoticeTable.repID, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.repID)));

                dataList.add(noticeMap);

            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
        // 每天全天问候
        // 查询是否有待办
        String alldaysql = "select * from LocateAllNoticeTable where displayAlarm=0 and isEnd=0 and postpone=1 and repID=0 and alarmClockTime!='' "
                + " order by alarmResultTime asc";
        String alltime = sp.getString(mContextApplication, ShareFile.USERFILE,
                ShareFile.ALLTIME, "23:59");
        try {
            Cursor cursor = sqldb.rawQuery(alldaysql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                noticeMap = new HashMap<String, String>();

                noticeMap.put(LocateAllNoticeTable.alarmId, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.alarmId)));

                noticeMap
                        .put(LocateAllNoticeTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.noticeContent)));
                noticeMap
                        .put(LocateAllNoticeTable.alarmType,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmType)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));
                noticeMap
                        .put(LocateAllNoticeTable.stateone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.stateone)));
                noticeMap
                        .put(LocateAllNoticeTable.statetwo,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.statetwo)));
                noticeMap.put(LocateAllNoticeTable.dateone, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.dateone)));
                noticeMap.put(LocateAllNoticeTable.datetwo, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.datetwo)));

                noticeMap.put(LocateAllNoticeTable.alarmSound, "g_207");
                String postpone = cursor.getString(cursor
                        .getColumnIndex(LocateAllNoticeTable.postpone));
                // String mytime = sp.getString(mContextApplication,
                // ShareFile.USERFILE,
                // ShareFile.ALLTIME, "08:58");
                Calendar cd = Calendar.getInstance();
                cd.setTime(DateUtil.parseDateTime(DateUtil
                        .formatDate(new Date()) + " " + alltime));
                String alarmResultTime = DateTimeHelper.formatDateTimetoString(
                        cd.getTime(), DateTimeHelper.FMT_yyyyMMddHHmmss);
                if (DateUtil.parseDateTimeSs(
                        DateUtil.formatDateTimeSs(cd.getTime())).getTime() > DateUtil
                        .parseDateTimeSs(currentTimeSs).getTime()) {

                } else {
                    Calendar cdx = Calendar.getInstance();
                    cdx.setTime(cd.getTime());
                    cdx.add(cdx.DATE, 1);
                    alarmResultTime = DateTimeHelper.formatDateTimetoString(
                            cdx.getTime(), DateTimeHelper.FMT_yyyyMMddHHmmss);
                }

                noticeMap.put(LocateAllNoticeTable.alarmResultTime,
                        alarmResultTime);

                noticeMap.put(LocateAllNoticeTable.alarmClockTime,
                        alarmResultTime);

                noticeMap
                        .put(LocateAllNoticeTable.beforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.beforTime)));
                noticeMap
                        .put(LocateAllNoticeTable.isAlarmClock,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
                noticeMap
                        .put(LocateAllNoticeTable.displayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.displayAlarm)));
                noticeMap
                        .put(LocateAllNoticeTable.postpone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.postpone)));
                noticeMap.put(LocateAllNoticeTable.repID, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.repID)));

                dataList.add(noticeMap);
            } else {
                String alltimesql = "select * from LocateAllNoticeTable where displayAlarm=0 and isEnd=0 and postpone=0 and repID=0 and alarmClockTime!='' and alarmResultTime > '"
                        + DateUtil.formatDateTimeSs(new Date())
                        + "' order by alarmResultTime asc";
                Cursor alltimecursor = sqldb.rawQuery(alltimesql, null);
                if (null != alltimecursor && alltimecursor.getCount() > 0) {
                    alltimecursor.moveToFirst();
                    noticeMap = new HashMap<String, String>();

                    noticeMap
                            .put(LocateAllNoticeTable.alarmId,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.alarmId)));

                    noticeMap
                            .put(LocateAllNoticeTable.noticeContent,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.noticeContent)));
                    noticeMap
                            .put(LocateAllNoticeTable.alarmType,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.alarmType)));

                    noticeMap
                            .put(LocateAllNoticeTable.alarmSoundDesc,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));
                    noticeMap
                            .put(LocateAllNoticeTable.stateone,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.stateone)));
                    noticeMap
                            .put(LocateAllNoticeTable.statetwo,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.statetwo)));
                    noticeMap
                            .put(LocateAllNoticeTable.dateone,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.dateone)));
                    noticeMap
                            .put(LocateAllNoticeTable.datetwo,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.datetwo)));

                    noticeMap.put(LocateAllNoticeTable.alarmSound, "g_207");
                    String postpone = alltimecursor.getString(alltimecursor
                            .getColumnIndex(LocateAllNoticeTable.postpone));
                    String alarmResultTime = alltimecursor
                            .getString(alltimecursor
                                    .getColumnIndex(LocateAllNoticeTable.alarmResultTime));
                    if (alarmResultTime.length() == 16) {
                        alarmResultTime = DateUtil.formatDateTimeSs(DateUtil
                                .parseDateTime(alarmResultTime));
                    }
                    noticeMap.put(LocateAllNoticeTable.alarmResultTime,
                            alarmResultTime);

                    noticeMap.put(LocateAllNoticeTable.alarmClockTime,
                            alarmResultTime);

                    noticeMap
                            .put(LocateAllNoticeTable.beforTime,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.beforTime)));
                    noticeMap
                            .put(LocateAllNoticeTable.isAlarmClock,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.isAlarmClock)));
                    noticeMap
                            .put(LocateAllNoticeTable.displayAlarm,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.displayAlarm)));
                    noticeMap
                            .put(LocateAllNoticeTable.postpone,
                                    alltimecursor.getString(alltimecursor
                                            .getColumnIndex(LocateAllNoticeTable.postpone)));
                    noticeMap.put(LocateAllNoticeTable.repID, cursor.getString(cursor.getColumnIndex(LocateAllNoticeTable.repID)));

                    dataList.add(noticeMap);
                }
            }
            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        List<Map<String, String>> newlist = new ArrayList<>();
        for (Map<String, String> map : dataList) {
            if (!newlist.contains(map)) {
                newlist.add(map);
            }
        }

        try {
            Collections.sort(newlist, new Comparator<Map<String, String>>() {
                public int compare(Map<String, String> o1,
                                   Map<String, String> o2) {
                    if (DateUtil.parseDateTimeSs(o1.get(LocateAllNoticeTable.alarmResultTime)).getTime()
                            > DateUtil.parseDateTimeSs(o2.get(LocateAllNoticeTable.alarmResultTime)).getTime()) {
                        return 1;
                    } else if ((DateUtil.parseDateTimeSs(o1.get(LocateAllNoticeTable.alarmResultTime)).getTime()
                            == DateUtil.parseDateTimeSs(o2.get(LocateAllNoticeTable.alarmResultTime)).getTime())) {
                        return 0;
                    } else {
                        return -1;
                    }
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }

        return newlist;
    }

    /**
     * 根据alarmid查询对应的日程id和重复id
     */
    public Map<String, String> getqueryschrepID(int alarmID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = new HashMap<String, String>();

        String sql = "select * from LocateAllNoticeTable where alarmId = "
                + alarmID;

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);

            while (cursor.moveToNext()) {
                noticeMap.put(LocateAllNoticeTable.alarmId, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.alarmId)));
                noticeMap
                        .put(LocateAllNoticeTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.noticeContent)));
                noticeMap
                        .put(LocateAllNoticeTable.alarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSoundDesc)));
                noticeMap
                        .put(LocateAllNoticeTable.alarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmSound)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmResultTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmResultTime)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmClockTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmClockTime)));

                noticeMap
                        .put(LocateAllNoticeTable.beforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.beforTime)));

                noticeMap
                        .put(LocateAllNoticeTable.alarmType,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.alarmType)));
                noticeMap.put(LocateAllNoticeTable.schID, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.schID)));
                noticeMap.put(LocateAllNoticeTable.repID, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.repID)));
                noticeMap.put(LocateAllNoticeTable.isEnd, cursor
                        .getString(cursor
                                .getColumnIndex(LocateAllNoticeTable.isEnd)));
                noticeMap
                        .put(LocateAllNoticeTable.postpone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllNoticeTable.postpone)));
                return noticeMap;

            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    /**
     * 清空闹钟表的所有数据
     */
    public void deleteclockData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from LocateAllNoticeTable where alarmId >= 0";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /******************************** 数据迁移 ****************************************************/
    /**
     * 删除日程表
     *
     * @return
     */
    public void deleteSchData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schID + " <= " + 0 + " and "
                + ScheduleTable.schAID + " = " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSchData1() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + ScheduleTable.ScheduleTable + " set "
                + ScheduleTable.schUpdateState + " = " + 3 + " where "
                + ScheduleTable.schID + " > " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 清空重复表
     *
     * @return
     */
    public void deleteRepData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + CLRepeatTable.CLRepeatTable + " where "
                + CLRepeatTable.repID + " < " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void deleteRepData1() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLRepeatTable.CLRepeatTable + " set "
                + CLRepeatTable.repUpdateState + " = " + 3 + " where "
                + CLRepeatTable.repID + " > " + 0 + " and "
                + CLRepeatTable.repUpdateState + " != " + 3;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public List<Map<String, String>> QueryOldSchUpdate() {
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(
                "/data/data/com.mission.schedule/databases/plan", null);
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from LocateAllNoticeTable"
                + " where tpId=0 and locateUpdateState!=3";
        try {
            Cursor cursor = db.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(LocateOldAllNoticeTable.alarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.alarmSound)));
                noticeMap
                        .put(LocateOldAllNoticeTable.alarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.alarmSoundDesc)));
                noticeMap
                        .put(LocateOldAllNoticeTable.beforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.beforTime)));
                noticeMap
                        .put(LocateOldAllNoticeTable.colorType,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.colorType)));
                noticeMap
                        .put(LocateOldAllNoticeTable.createTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.createTime)));
                noticeMap
                        .put(LocateOldAllNoticeTable.displayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.displayAlarm)));
                noticeMap
                        .put(LocateOldAllNoticeTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.noticeContent)));
                noticeMap
                        .put(LocateOldAllNoticeTable.noticeDate,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.noticeDate)));
                noticeMap
                        .put(LocateOldAllNoticeTable.postpone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.postpone)));
                noticeMap.put(LocateOldAllNoticeTable.tpId, cursor
                        .getString(cursor
                                .getColumnIndex(LocateOldAllNoticeTable.tpId)));
                noticeMap
                        .put(LocateOldAllNoticeTable.teamNoticeReadState,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.teamNoticeReadState)));
                noticeMap
                        .put(LocateOldAllNoticeTable.noticeIsStarred,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.noticeIsStarred)));
                noticeMap
                        .put(LocateOldAllNoticeTable.alarmClockTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.alarmClockTime)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public List<Map<String, String>> QueryRepeatData() {
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(
                "/data/data/com.mission.schedule/databases/plan", null);
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from LocateRepeatNoticeTable where locateUpdateState!=3";
        try {
            Cursor cursor = db.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpAlarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpAlarmSound)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpAlarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpAlarmSoundDesc)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpBeforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpBeforTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpContent)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpCreateTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpCreateTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDataType,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDataType)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDate,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDate)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDisplayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDisplayAlarm)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.locateNextCreatTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.locateNextCreatTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpCurWeek,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpCurWeek)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDay,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDay)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpMonthDay,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpMonthDay)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpLcDate,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpLcDate)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public List<Map<String, String>> QueryYestodayData() {
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(
                "/data/data/com.mission.schedule/databases/plan", null);
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from LocateAllMemoTable where locateUpdateState!=3";
        try {
            Cursor cursor = db.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(LocateAllMemoTable.createTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllMemoTable.createTime)));
                noticeMap
                        .put(LocateAllMemoTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllMemoTable.noticeContent)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public List<Map<String, String>> QueryOldSchUpdate1() {
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(Environment
                .getExternalStorageDirectory().getPath()
                + "/YourAppDataFolder/plan", null);
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from LocateAllNoticeTable"
                + " where tpId=0 and locateUpdateState!=3";
        try {
            Cursor cursor = db.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(LocateOldAllNoticeTable.alarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.alarmSound)));
                noticeMap
                        .put(LocateOldAllNoticeTable.alarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.alarmSoundDesc)));
                noticeMap
                        .put(LocateOldAllNoticeTable.beforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.beforTime)));
                noticeMap
                        .put(LocateOldAllNoticeTable.colorType,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.colorType)));
                noticeMap
                        .put(LocateOldAllNoticeTable.createTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.createTime)));
                noticeMap
                        .put(LocateOldAllNoticeTable.displayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.displayAlarm)));
                noticeMap
                        .put(LocateOldAllNoticeTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.noticeContent)));
                noticeMap
                        .put(LocateOldAllNoticeTable.noticeDate,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.noticeDate)));
                noticeMap
                        .put(LocateOldAllNoticeTable.postpone,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.postpone)));
                noticeMap.put(LocateOldAllNoticeTable.tpId, cursor
                        .getString(cursor
                                .getColumnIndex(LocateOldAllNoticeTable.tpId)));
                noticeMap
                        .put(LocateOldAllNoticeTable.teamNoticeReadState,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.teamNoticeReadState)));
                noticeMap
                        .put(LocateOldAllNoticeTable.noticeIsStarred,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.noticeIsStarred)));
                noticeMap
                        .put(LocateOldAllNoticeTable.alarmClockTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateOldAllNoticeTable.alarmClockTime)));
                dataList.add(noticeMap);
            }
            cursor.close();
            db.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public List<Map<String, String>> QueryRepeatData1() {
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(Environment
                .getExternalStorageDirectory().getPath()
                + "/YourAppDataFolder/plan", null);
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from LocateRepeatNoticeTable where locateUpdateState!=3";
        try {
            Cursor cursor = db.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpAlarmSound,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpAlarmSound)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpAlarmSoundDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpAlarmSoundDesc)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpBeforTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpBeforTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpContent)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpCreateTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpCreateTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDataType,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDataType)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDate,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDate)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDisplayAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDisplayAlarm)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.locateNextCreatTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.locateNextCreatTime)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpCurWeek,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpCurWeek)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpDay,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpDay)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpMonthDay,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpMonthDay)));
                noticeMap
                        .put(LocateRepeatNoticeTable.key_tpLcDate,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateRepeatNoticeTable.key_tpLcDate)));
                dataList.add(noticeMap);
            }
            cursor.close();
            db.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public List<Map<String, String>> QueryYestodayData1() {
        SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(Environment
                .getExternalStorageDirectory().getPath()
                + "/YourAppDataFolder/plan", null);
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "select * from LocateAllMemoTable where locateUpdateState!=3";
        try {
            Cursor cursor = db.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap
                        .put(LocateAllMemoTable.createTime,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllMemoTable.createTime)));
                noticeMap
                        .put(LocateAllMemoTable.noticeContent,
                                cursor.getString(cursor
                                        .getColumnIndex(LocateAllMemoTable.noticeContent)));
                dataList.add(noticeMap);
            }
            cursor.close();
            db.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public boolean insertYestodayData(String schContent, String schTime,
                                      String schCreateTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        String yestoday = DateUtil.formatDate(calendar.getTime());
        int ID = getLocalId(1, "ScheduleTable", ScheduleTable.ID);
        schID = getLocalId(-1, "ScheduleTable", ScheduleTable.schID);
        String sql = "insert into ScheduleTable(ID,schID,schContent,schDate,schTime,"
                + "schIsAlarm, schBeforeTime,schDisplayTime, schIsPostpone,schIsImportant,"
                + "schColorType, schIsEnd, schCreateTime,schTags, schSourceType,schSourceDesc,"
                + "schSourceDescSpare, schRepeatID, schRepeatDate,schUpdateTime, schUpdateState,"
                + " schOpenState,schRepeatLink, schRingDesc, schRingCode,schcRecommendName, "
                + "schRead, schAID, schAType,schWebURL, schImagePath, schFocusState,schFriendID,"
                + " schcRecommendId) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ID, schID,
                StringUtils.getIsStringEqulesNull(schContent), yestoday,
                StringUtils.getIsStringEqulesNull(schTime), 1, 0, 1, 0, 0, 0,
                0, StringUtils.getIsStringEqulesNull(schCreateTime), "", 0, "",
                "", 0, "", StringUtils.getIsStringEqulesNull(schCreateTime), 1,
                0, 0, "完成任务", "g_88", "", 0, 0, 0, "", "", 0, 0, 0};
        // String sql = "insert into ScheduleTable values(" + id + " , " + schID
        // + ",'" + schContent + "','" + yestoday + "','" + schTime + "',"
        // + 1 + "," + 0 + "," + 1 + "," + 0 + "," + 0 + "," + 0 + "," + 0
        // + ",'" + schCreateTime + "','" + "" + "'," + 0 + ",'" +""
        // + "','" + "" + "'," + 0 + ",'" + "" + "','" + schCreateTime
        // + "'," + 1 + "," + 0 + "," + 0 + ",'" + "完成任务" + "','" + "g_88"
        // + "','" + "" + "'," + 0 + " , " + 0 + " , " + 0 + " , '" + ""
        // + "', '" + "" + "'," + 0 + "," + 0 + "," + 0 + ")";
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /*****************************************
     * 新版好友消息新表
     ************************************************/
    // 插入发送的消息
    public boolean insertMessageSendData(Integer nfmSendId, Integer nfmGetId,
                                         Integer nfmCalendarId, Integer nfmOpenState, Integer nfmStatus,
                                         Integer nfmIsAlarm, Integer nfmPostpone, Integer nfmColorType,
                                         Integer nfmDisplayTime, Integer nfmBeforeTime,
                                         Integer nfmSourceType, Integer nfmType, Integer nfmAType,
                                         Integer nfmInSTable, Integer nfmIsEnd, Integer nfmDownState,
                                         Integer nfmPostState, String nfmParameter, String nfmContent,
                                         String nfmDate, String nfmTime, String nfmSourceDesc,
                                         String nfmSourceDescSpare, String nfmTags, String nfmRingDesc,
                                         String nfmRingCode, String nfmStartDate,
                                         String nfmInitialCreatedTime, String nfmLastCreatedTime,
                                         String nfmNextCreatedTime, String nfmWebURL, String nfmImagePath,
                                         String nfmSendName, String nfmRemark, Integer nfmUpdateState,
                                         Integer nfmPId, Integer nfmSubState, String nfmSubDate,
                                         Integer nfmCState, Integer nfmSubEnd, String nfmSubEndDate,
                                         Integer nfmIsPuase, String parReamrk, String nfmCreateTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        nfmId = getLocalId(-1, "CLNFMessage", CLNFMessage.nfmId);
        String sql = "insert into CLNFMessage(nfmId, nfmSendId, nfmGetId,nfmCalendarId, "
                + "nfmOpenState, nfmStatus,nfmIsAlarm, nfmPostpone,nfmColorType,nfmDisplayTime,"
                + " nfmBeforeTime,nfmSourceType,nfmType,  nfmAType,nfmInSTable, "
                + "nfmIsEnd,nfmDownState,nfmPostState,nfmParameter,nfmContent,nfmDate, "
                + "nfmTime, nfmSourceDesc,nfmSourceDescSpare, nfmTags,nfmRingDesc,nfmRingCode,"
                + " nfmStartDate,nfmInitialCreatedTime, nfmLastCreatedTime,nfmNextCreatedTime,"
                + "nfmWebURL, nfmImagePath,nfmSendName, nfmRemark, nfmUpdateState,nfmPId, "
                + "nfmSubState, nfmSubDate,nfmCState, nfmSubEnd, nfmSubEndDate,nfmIsPuase,"
                + "parReamrk,nfmCreateTime) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{nfmId, nfmSendId, nfmGetId,
                nfmCalendarId, nfmOpenState, nfmStatus, nfmIsAlarm,
                nfmPostpone, nfmColorType, nfmDisplayTime, nfmBeforeTime,
                nfmSourceType, nfmType, nfmAType, nfmInSTable, nfmIsEnd,
                nfmDownState, nfmPostState,
                StringUtils.getIsStringEqulesNull(nfmParameter),
                StringUtils.getIsStringEqulesNull(nfmContent),
                StringUtils.getIsStringEqulesNull(nfmDate),
                StringUtils.getIsStringEqulesNull(nfmTime),
                StringUtils.getIsStringEqulesNull(nfmSourceDesc),
                StringUtils.getIsStringEqulesNull(nfmSourceDescSpare),
                StringUtils.getIsStringEqulesNull(nfmTags),
                StringUtils.getIsStringEqulesNull(nfmRingDesc),
                StringUtils.getIsStringEqulesNull(nfmRingCode),
                StringUtils.getIsStringEqulesNull(nfmStartDate),
                StringUtils.getIsStringEqulesNull(nfmInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmLastCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmNextCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmWebURL),
                StringUtils.getIsStringEqulesNull(nfmImagePath),
                StringUtils.getIsStringEqulesNull(nfmSendName),
                StringUtils.getIsStringEqulesNull(nfmRemark), nfmUpdateState,
                nfmPId, nfmSubState,
                StringUtils.getIsStringEqulesNull(nfmSubDate), nfmCState,
                nfmSubEnd, StringUtils.getIsStringEqulesNull(nfmSubEndDate),
                nfmIsPuase, StringUtils.getIsStringEqulesNull(parReamrk),
                StringUtils.getIsStringEqulesNull(nfmCreateTime)};
        // String sql = "insert into CLNFMessage values(" + nfmId + ","
        // + nfmSendId + "," + nfmGetId + "," + nfmCalendarId + ","
        // + nfmOpenState + "," + nfmStatus + "," + nfmIsAlarm + ","
        // + nfmPostpone + "," + nfmColorType + "," + nfmDisplayTime + ","
        // + nfmBeforeTime + "," + nfmSourceType + "," + nfmType + ","
        // + nfmAType + "," + nfmInSTable + "," + nfmIsEnd + ","
        // + nfmDownState + "," + nfmPostState + ",'" + nfmParameter
        // + "','" + nfmContent + "','" + nfmDate + "','" + nfmTime
        // + "','" + nfmSourceDesc + "','" + nfmSourceDescSpare + "','"
        // + nfmTags + "' , '" + nfmRingDesc + "','" + nfmRingCode + "','"
        // + nfmStartDate + "','" + nfmInitialCreatedTime + "','"
        // + nfmLastCreatedTime + "','" + nfmNextCreatedTime + "','"
        // + nfmWebURL + "','" + nfmImagePath + "','" + nfmSendName
        // + "','" + nfmRemark + "'," + nfmUpdateState + "," + nfmPId
        // + "," + nfmSubState + ",'" + nfmSubDate + "'," + nfmCState
        // + "," + nfmSubEnd + ",'" + nfmSubEndDate + "', " + nfmIsPuase
        // + ",'" + parReamrk + "' , '" + nfmCreateTime + "')";
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 从网上下载下来的数据
     *
     * @return
     */
    public boolean insertIntnetMessageSendData(Integer nfmId,
                                               Integer nfmSendId, Integer nfmGetId, Integer nfmCalendarId,
                                               Integer nfmOpenState, Integer nfmStatus, Integer nfmIsAlarm,
                                               Integer nfmPostpone, Integer nfmColorType, Integer nfmDisplayTime,
                                               Integer nfmBeforeTime, Integer nfmSourceType, Integer nfmType,
                                               Integer nfmAType, Integer nfmInSTable, Integer nfmIsEnd,
                                               Integer nfmDownState, Integer nfmPostState, String nfmParameter,
                                               String nfmContent, String nfmDate, String nfmTime,
                                               String nfmSourceDesc, String nfmSourceDescSpare, String nfmTags,
                                               String nfmRingDesc, String nfmRingCode, String nfmStartDate,
                                               String nfmInitialCreatedTime, String nfmLastCreatedTime,
                                               String nfmNextCreatedTime, String nfmWebURL, String nfmImagePath,
                                               String nfmSendName, String nfmRemark, Integer nfmUpdateState,
                                               Integer nfmPId, Integer nfmSubState, String nfmSubDate,
                                               Integer nfmCState, Integer nfmSubEnd, String nfmSubEndDate,
                                               Integer nfmIsPuase, String parReamrk, String nfmCreateTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "insert into CLNFMessage(nfmId, nfmSendId, nfmGetId,nfmCalendarId, "
                + "nfmOpenState, nfmStatus,nfmIsAlarm, nfmPostpone,nfmColorType,nfmDisplayTime,"
                + " nfmBeforeTime,nfmSourceType,nfmType,  nfmAType,nfmInSTable, "
                + "nfmIsEnd,nfmDownState,nfmPostState,nfmParameter,nfmContent,nfmDate, "
                + "nfmTime, nfmSourceDesc,nfmSourceDescSpare, nfmTags,nfmRingDesc,nfmRingCode,"
                + " nfmStartDate,nfmInitialCreatedTime, nfmLastCreatedTime,nfmNextCreatedTime,"
                + "nfmWebURL, nfmImagePath,nfmSendName, nfmRemark, nfmUpdateState,nfmPId, "
                + "nfmSubState, nfmSubDate,nfmCState, nfmSubEnd, nfmSubEndDate,nfmIsPuase,"
                + "parReamrk,nfmCreateTime) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{nfmId, nfmSendId, nfmGetId,
                nfmCalendarId, nfmOpenState, nfmStatus, nfmIsAlarm,
                nfmPostpone, nfmColorType, nfmDisplayTime, nfmBeforeTime,
                nfmSourceType, nfmType, nfmAType, nfmInSTable, nfmIsEnd,
                nfmDownState, nfmPostState,
                StringUtils.getIsStringEqulesNull(nfmParameter),
                StringUtils.getIsStringEqulesNull(nfmContent),
                StringUtils.getIsStringEqulesNull(nfmDate),
                StringUtils.getIsStringEqulesNull(nfmTime),
                StringUtils.getIsStringEqulesNull(nfmSourceDesc),
                StringUtils.getIsStringEqulesNull(nfmSourceDescSpare),
                StringUtils.getIsStringEqulesNull(nfmTags),
                StringUtils.getIsStringEqulesNull(nfmRingDesc),
                StringUtils.getIsStringEqulesNull(nfmRingCode),
                StringUtils.getIsStringEqulesNull(nfmStartDate),
                StringUtils.getIsStringEqulesNull(nfmInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmLastCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmNextCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmWebURL),
                StringUtils.getIsStringEqulesNull(nfmImagePath),
                StringUtils.getIsStringEqulesNull(nfmSendName),
                StringUtils.getIsStringEqulesNull(nfmRemark), nfmUpdateState,
                nfmPId, nfmSubState,
                StringUtils.getIsStringEqulesNull(nfmSubDate), nfmCState,
                nfmSubEnd, StringUtils.getIsStringEqulesNull(nfmSubEndDate),
                nfmIsPuase, StringUtils.getIsStringEqulesNull(parReamrk),
                StringUtils.getIsStringEqulesNull(nfmCreateTime)};
        // String sql = "insert into CLNFMessage values(" + nfmId + ","
        // + nfmSendId + "," + nfmGetId + "," + nfmCalendarId + ","
        // + nfmOpenState + "," + nfmStatus + "," + nfmIsAlarm + ","
        // + nfmPostpone + "," + nfmColorType + "," + nfmDisplayTime + ","
        // + nfmBeforeTime + "," + nfmSourceType + "," + nfmType + ","
        // + nfmAType + "," + nfmInSTable + "," + nfmIsEnd + ","
        // + nfmDownState + "," + nfmPostState + ",'" + nfmParameter
        // + "','" + nfmContent + "','" + nfmDate + "','" + nfmTime
        // + "','" + nfmSourceDesc + "','" + nfmSourceDescSpare + "','"
        // + nfmTags + "' , '" + nfmRingDesc + "','" + nfmRingCode + "','"
        // + nfmStartDate + "','" + nfmInitialCreatedTime + "','"
        // + nfmLastCreatedTime + "','" + nfmNextCreatedTime + "','"
        // + nfmWebURL + "','" + nfmImagePath + "','" + nfmSendName
        // + "','" + nfmRemark + "'," + nfmUpdateState + "," + nfmPId
        // + "," + nfmSubState + ",'" + nfmSubDate + "'," + nfmCState
        // + "," + nfmSubEnd + ",'" + nfmSubEndDate + "', " + nfmIsPuase
        // + ",'" + parReamrk + "' , '" + nfmCreateTime + "')";
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public List<Map<String, String>> queryAllLocalFriendsData(int timeType,
                                                              int firendID) throws Exception {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String sql = "";
        String yestoday;//昨天
        String today;// 今天
        String tomorrow;// 明天
        String inweek;// 一周以内
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        yestoday = DateUtil.formatDate(calendar.getTime());
        calendar.setTime(new Date());
        today = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 1);
        tomorrow = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 7);
        inweek = DateUtil.formatDate(calendar.getTime());

        switch (timeType) {
            case -1:// 查询所有nfmupdate为1 新建的消息进行同步上传
                // sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                // + CLNFMessage.nfmUpdateState + " = " + 1 + " and("
                // + CLNFMessage.nfmPId + " = " + 0 + " or "
                // + CLNFMessage.nfmSubState + " = " + 1 + " or "
                // + CLNFMessage.nfmSubState + " = " + 2
                // + ") order by nfmDate desc,nfmDisplayTime asc,nfmTime asc";
                sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                        + CLNFMessage.nfmUpdateState + " = " + 1
                        + " order by nfmDate desc,nfmDisplayTime asc,nfmTime asc";
                break;
            case -2:// 查询所有nfmupdate为2 修改的消息进行同步上传
                // sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                // + CLNFMessage.nfmUpdateState + " = " + 2 + " and ("
                // + CLNFMessage.nfmPId + " = " + 0 + " or "
                // + CLNFMessage.nfmSubState + " = " + 1 + " or "
                // + CLNFMessage.nfmSubState + " = " + 2
                // + ") order by nfmDate desc,nfmDisplayTime asc,nfmTime asc";
                sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                        + CLNFMessage.nfmUpdateState + " = " + 2
                        + " order by nfmDate desc,nfmDisplayTime asc,nfmTime asc";
                break;
            case -3:// 查询所有nfmupdate为3 删除的消息进行同步上传
                // sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                // + CLNFMessage.nfmUpdateState + " = " + 3 + " and ("
                // + CLNFMessage.nfmPId + " = " + 0 + " or "
                // + CLNFMessage.nfmSubState + " = " + 1 + " or "
                // + CLNFMessage.nfmSubState + " = " + 2
                // + ") order by nfmDate desc,nfmDisplayTime asc,nfmTime asc";
                sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                        + CLNFMessage.nfmUpdateState + " = " + 3
                        + " order by nfmDate desc,nfmDisplayTime asc,nfmTime asc";
                break;
            case 0:// 0 以前+未结束+顺延
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate<'"
                        + DateUtil.formatDate(new Date())
                        + "'and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmPostState
                        + " != "
                        + 1
                        + " and "
                        + CLNFMessage.nfmPostpone
                        + " = "
                        + 1
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate desc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 1:// 待办 今天以前+全天+未结束+自动顺延
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate=='"
                        + DateUtil.formatDate(new Date())
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmDisplayTime
                        + " != "
                        + 1
                        + " and "
                        + CLNFMessage.nfmPostpone
                        + " != "
                        + 0
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate asc,nfmDisplayTime asc,nfmCreateTime desc,nfmTime desc";
                break;
            case 2:// 今天 + 不顺延 + 显示时间
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate =='"
                        + DateUtil.formatDate(new Date())
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and ("
                        + CLNFMessage.nfmDisplayTime
                        + " != "
                        + 0
                        + " or "
                        + CLNFMessage.nfmPostpone
                        + " != "
                        + 1
                        + ") order by nfmDate asc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 3:// 明天
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate ='"
                        + tomorrow
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate asc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 4:// 一周以内
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate <'"
                        + inweek
                        + "' and "
                        + " nfmDate >'"
                        + tomorrow
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate asc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 5:// 一周以外
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate >='"
                        + inweek
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate asc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 6:
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + "nfmDate =='"
                        + DateUtil.formatDate(new Date())
                        + "' and "
                        + CLNFMessage.nfmIsEnd
                        + " = "
                        + 0
                        + " and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate asc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;

            case 7:// 昨天
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + CLNFMessage.nfmDate
                        + " ='"
                        + yestoday
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate desc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 8:// 昨天以前
                sql = "select * from "
                        + CLNFMessage.CLNFMessage
                        + " where "
                        + CLNFMessage.nfmDate
                        + " < '"
                        + yestoday
                        + "' and "
                        + CLNFMessage.nfmUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLNFMessage.nfmGetId
                        + " = "
                        + firendID
                        + " and "
                        + CLNFMessage.nfmStatus
                        + " = "
                        + 1
                        + " order by nfmDate desc,nfmDisplayTime asc,nfmTime asc,nfmId asc";
                break;
            case 9:// 重复查询
                sql = "select * from " + CLNFMessage.CLNFMessage + " where "
                        + CLNFMessage.nfmUpdateState + " != " + 3 + " and "
                        + CLNFMessage.nfmStatus + " = " + 2 + " and "
                        + CLNFMessage.nfmGetId + " = " + firendID
                        + " order by nfmTime asc";
                break;
        }
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLNFMessage.nfmId, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmId)));
                noticeMap.put(CLNFMessage.nfmSendId, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmSendId)));
                noticeMap.put(CLNFMessage.nfmGetId, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmGetId)));
                noticeMap.put(CLNFMessage.nfmCalendarId, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmCalendarId)));
                noticeMap.put(CLNFMessage.nfmOpenState, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmOpenState)));
                noticeMap.put(CLNFMessage.nfmStatus, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmStatus)));
                noticeMap.put(CLNFMessage.nfmIsAlarm, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmIsAlarm)));
                noticeMap.put(CLNFMessage.nfmPostpone, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmPostpone)));
                noticeMap.put(CLNFMessage.nfmColorType, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmColorType)));
                noticeMap.put(CLNFMessage.nfmDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmDisplayTime)));
                noticeMap.put(CLNFMessage.nfmBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmBeforeTime)));
                noticeMap.put(CLNFMessage.nfmSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmSourceType)));
                noticeMap.put(CLNFMessage.nfmType, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmType)));
                noticeMap.put(CLNFMessage.nfmAType, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmAType)));
                noticeMap.put(CLNFMessage.nfmInSTable, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmInSTable)));
                noticeMap.put(CLNFMessage.nfmIsEnd, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmIsEnd)));
                noticeMap.put(CLNFMessage.nfmDownState, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmDownState)));
                noticeMap.put(CLNFMessage.nfmPostState, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmPostState)));
                noticeMap.put(CLNFMessage.nfmUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmUpdateState)));
                noticeMap.put(CLNFMessage.nfmPId, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmPId)));
                noticeMap.put(CLNFMessage.nfmSubState, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmSubState)));
                noticeMap.put(CLNFMessage.nfmSubEnd, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmSubEnd)));
                noticeMap.put(CLNFMessage.nfmCState, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmCState)));
                noticeMap.put(CLNFMessage.nfmParameter, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmParameter)));
                noticeMap.put(CLNFMessage.nfmContent, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmContent)));
                noticeMap.put(CLNFMessage.nfmDate, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmDate)));
                noticeMap.put(CLNFMessage.nfmTime, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmTime)));
                noticeMap.put(CLNFMessage.nfmSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmSourceDesc)));
                noticeMap
                        .put(CLNFMessage.nfmSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLNFMessage.nfmSourceDescSpare)));
                noticeMap.put(CLNFMessage.nfmTags, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmTags)));
                noticeMap.put(CLNFMessage.nfmRingDesc, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmRingDesc)));
                noticeMap.put(CLNFMessage.nfmRingCode, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmRingCode)));
                noticeMap.put(CLNFMessage.nfmStartDate, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmStartDate)));
                noticeMap
                        .put(CLNFMessage.nfmInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLNFMessage.nfmInitialCreatedTime)));
                noticeMap
                        .put(CLNFMessage.nfmLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLNFMessage.nfmLastCreatedTime)));
                noticeMap
                        .put(CLNFMessage.nfmNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLNFMessage.nfmNextCreatedTime)));
                noticeMap.put(CLNFMessage.nfmWebURL, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmWebURL)));
                noticeMap.put(CLNFMessage.nfmImagePath, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmImagePath)));
                noticeMap.put(CLNFMessage.nfmSendName, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmSendName)));
                noticeMap.put(CLNFMessage.nfmSubDate, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmSubDate)));
                noticeMap.put(CLNFMessage.nfmRemark, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmRemark)));
                noticeMap.put(CLNFMessage.nfmSubEndDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmSubEndDate)));
                noticeMap.put(CLNFMessage.nfmIsPuase, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.nfmIsPuase)));
                noticeMap.put(CLNFMessage.parReamrk, cursor.getString(cursor
                        .getColumnIndex(CLNFMessage.parReamrk)));
                noticeMap.put(CLNFMessage.nfmCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLNFMessage.nfmCreateTime)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    /**
     * 修改新好友消息信息
     */
    public void updateNewFriendsData(Integer oldID, Integer newID,
                                     Integer calendId, Integer updateState) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmId + " = " + newID + " , "
                + CLNFMessage.nfmCalendarId + " = " + calendId + " , "
                + CLNFMessage.nfmUpdateState + " = " + updateState + " where "
                + CLNFMessage.nfmId + " = " + oldID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改新好友重复消息子记事
     */
    public void updateNewFriendsChildData(Integer oldID, Integer newID,
                                          Integer calendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmPId + " = " + newID + " , "
                + CLNFMessage.nfmCalendarId + " = " + calendId + " where "
                + CLNFMessage.nfmPId + " = " + oldID + " and ("
                + CLNFMessage.nfmSubState + " = " + 0 + " or "
                + CLNFMessage.nfmSubState + " = " + 3 + ")";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改下载下来相同id新好友消息信息
     */
    public void alterNewFriendsData1(Integer nfmId, Integer nfmSendId,
                                     Integer nfmGetId, Integer nfmCalendarId, Integer nfmOpenState,
                                     Integer nfmStatus, Integer nfmIsAlarm, Integer nfmPostpone,
                                     Integer nfmColorType, Integer nfmDisplayTime,
                                     Integer nfmBeforeTime, Integer nfmSourceType, Integer nfmType,
                                     Integer nfmAType, Integer nfmInSTable, Integer nfmIsEnd,
                                     Integer nfmDownState, Integer nfmPostState, String nfmParameter,
                                     String nfmContent, String nfmDate, String nfmTime,
                                     String nfmSourceDesc, String nfmSourceDescSpare, String nfmTags,
                                     String nfmRingDesc, String nfmRingCode, String nfmStartDate,
                                     String nfmInitialCreatedTime, String nfmLastCreatedTime,
                                     String nfmNextCreatedTime, String nfmWebURL, String nfmImagePath,
                                     String nfmSendName, String nfmRemark, Integer nfmUpdateState,
                                     Integer nfmPId, Integer nfmSubState, String nfmSubDate,
                                     Integer nfmCState, Integer nfmSubEnd, String nfmSubEndDate,
                                     Integer nfmIsPuase, String parReamrk) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmId + " = ?" + " , " + CLNFMessage.nfmSendId
                + " = ?" + " , " + CLNFMessage.nfmGetId + " = ?" + " , "
                + CLNFMessage.nfmCalendarId + " = ?" + " , "
                + CLNFMessage.nfmOpenState + " = ?" + " , "
                + CLNFMessage.nfmStatus + " = ?" + " , "
                + CLNFMessage.nfmIsAlarm + " = ?" + " , "
                + CLNFMessage.nfmPostpone + " = ?" + " , "
                + CLNFMessage.nfmColorType + " = ?" + " , "
                + CLNFMessage.nfmDisplayTime + " = ?" + " , "
                + CLNFMessage.nfmBeforeTime + " = ?" + " , "
                + CLNFMessage.nfmSourceType + " = ?" + " , "
                + CLNFMessage.nfmType + " = ?" + " , " + CLNFMessage.nfmAType
                + " = ?" + " , " + CLNFMessage.nfmInSTable + " = ?" + " , "
                + CLNFMessage.nfmIsEnd + " = ?" + " , "
                + CLNFMessage.nfmDownState + " = ?" + " , "
                + CLNFMessage.nfmPostState + " = ?" + " , "
                + CLNFMessage.nfmParameter + " = ?" + ", "
                + CLNFMessage.nfmContent + " = ?" + " , " + CLNFMessage.nfmDate
                + " = ?" + " , " + CLNFMessage.nfmTime + " = ?" + " , "
                + CLNFMessage.nfmSourceDesc + " = ?" + ", "
                + CLNFMessage.nfmSourceDescSpare + " = ?" + ", "
                + CLNFMessage.nfmTags + " = ?" + " , "
                + CLNFMessage.nfmRingDesc + " = ?" + " , "
                + CLNFMessage.nfmRingCode + " = ?" + ", "
                + CLNFMessage.nfmStartDate + " = ?" + " , "
                + CLNFMessage.nfmInitialCreatedTime + " = ?" + ", "
                + CLNFMessage.nfmLastCreatedTime + " = ?" + ", "
                + CLNFMessage.nfmNextCreatedTime + " = ?" + ", "
                + CLNFMessage.nfmWebURL + " = ?" + ", "
                + CLNFMessage.nfmImagePath + " = ?" + ", "
                + CLNFMessage.nfmSendName + " = ?" + ", "
                + CLNFMessage.nfmRemark + " = ?" + ", "
                + CLNFMessage.nfmUpdateState + " = ?" + ", "
                + CLNFMessage.nfmPId + " = ?" + ", " + CLNFMessage.nfmSubState
                + " = ?" + " , " + CLNFMessage.nfmSubDate + " = ?" + ", "
                + CLNFMessage.nfmCState + " = ?" + ", " + CLNFMessage.nfmSubEnd
                + " = ?" + ", " + CLNFMessage.nfmSubEndDate + " = ?" + ", "
                + CLNFMessage.nfmIsPuase + " = ?" + ", "
                + CLNFMessage.parReamrk + " = ?" + " where "
                + CLNFMessage.nfmId + " = " + nfmId;
        Object[] mValue = new Object[]{nfmId, nfmSendId, nfmGetId,
                nfmCalendarId, nfmOpenState, nfmStatus, nfmIsAlarm,
                nfmPostpone, nfmColorType, nfmDisplayTime, nfmBeforeTime,
                nfmSourceType, nfmType, nfmAType, nfmInSTable, nfmIsEnd,
                nfmDownState, nfmPostState,
                StringUtils.getIsStringEqulesNull(nfmParameter),
                StringUtils.getIsStringEqulesNull(nfmContent),
                StringUtils.getIsStringEqulesNull(nfmDate),
                StringUtils.getIsStringEqulesNull(nfmTime),
                StringUtils.getIsStringEqulesNull(nfmSourceDesc),
                StringUtils.getIsStringEqulesNull(nfmSourceDescSpare),
                StringUtils.getIsStringEqulesNull(nfmTags),
                StringUtils.getIsStringEqulesNull(nfmRingDesc),
                StringUtils.getIsStringEqulesNull(nfmRingCode),
                StringUtils.getIsStringEqulesNull(nfmStartDate),
                StringUtils.getIsStringEqulesNull(nfmInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmLastCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmNextCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmWebURL),
                StringUtils.getIsStringEqulesNull(nfmImagePath),
                StringUtils.getIsStringEqulesNull(nfmSendName),
                StringUtils.getIsStringEqulesNull(nfmRemark), nfmUpdateState,
                nfmPId, nfmSubState,
                StringUtils.getIsStringEqulesNull(nfmSubDate), nfmCState,
                nfmSubEnd, StringUtils.getIsStringEqulesNull(nfmSubEndDate),
                nfmIsPuase, StringUtils.getIsStringEqulesNull(parReamrk)};
        // String sql = "update " + CLNFMessage.CLNFMessage + " set "
        // + CLNFMessage.nfmId + " = " + nfmId + " , "
        // + CLNFMessage.nfmSendId + " = " + nfmSendId + " , "
        // + CLNFMessage.nfmGetId + " = " + nfmGetId + " , "
        // + CLNFMessage.nfmCalendarId + " = " + nfmCalendarId + " , "
        // + CLNFMessage.nfmOpenState + " = " + nfmOpenState + " , "
        // + CLNFMessage.nfmStatus + " = " + nfmStatus + " , "
        // + CLNFMessage.nfmIsAlarm + " = " + nfmIsAlarm + " , "
        // + CLNFMessage.nfmPostpone + " = " + nfmPostpone + " , "
        // + CLNFMessage.nfmColorType + " = " + nfmColorType + " , "
        // + CLNFMessage.nfmDisplayTime + " = " + nfmDisplayTime + " , "
        // + CLNFMessage.nfmBeforeTime + " = " + nfmBeforeTime + " , "
        // + CLNFMessage.nfmSourceType + " = " + nfmSourceType + " , "
        // + CLNFMessage.nfmType + " = " + nfmType + " , "
        // + CLNFMessage.nfmAType + " = " + nfmAType + " , "
        // + CLNFMessage.nfmInSTable + " = " + nfmInSTable + " , "
        // + CLNFMessage.nfmIsEnd + " = " + nfmIsEnd + " , "
        // + CLNFMessage.nfmDownState + " = " + nfmDownState + " , "
        // + CLNFMessage.nfmPostState + " = " + nfmPostState + " , "
        // + CLNFMessage.nfmParameter + " = '" + nfmParameter + "' , "
        // + CLNFMessage.nfmContent + " = '" + nfmContent + "' , "
        // + CLNFMessage.nfmDate + " = '" + nfmDate + "' , "
        // + CLNFMessage.nfmTime + " = '" + nfmTime + "' , "
        // + CLNFMessage.nfmSourceDesc + " = '" + nfmSourceDesc + "' , "
        // + CLNFMessage.nfmSourceDescSpare + " = '" + nfmSourceDescSpare
        // + "' , " + CLNFMessage.nfmTags + " = '" + nfmTags + "' , "
        // + CLNFMessage.nfmRingDesc + " = '" + nfmRingDesc + "' , "
        // + CLNFMessage.nfmRingCode + " = '" + nfmRingCode + "' , "
        // + CLNFMessage.nfmStartDate + " = '" + nfmStartDate + "' , "
        // + CLNFMessage.nfmInitialCreatedTime + " = '"
        // + nfmInitialCreatedTime + "' , "
        // + CLNFMessage.nfmLastCreatedTime + " = '" + nfmLastCreatedTime
        // + "' , " + CLNFMessage.nfmNextCreatedTime + " ='"
        // + nfmNextCreatedTime + "' , " + CLNFMessage.nfmWebURL + " = '"
        // + nfmWebURL + "' , " + CLNFMessage.nfmImagePath + " = '"
        // + nfmImagePath + "' , " + CLNFMessage.nfmSendName + " = '"
        // + nfmSendName + "' , " + CLNFMessage.nfmRemark + " ='"
        // + nfmRemark + "' , " + CLNFMessage.nfmUpdateState + " = "
        // + nfmUpdateState + " , " + CLNFMessage.nfmPId + " = " + nfmPId
        // + " , " + CLNFMessage.nfmSubState + " = " + nfmSubState + " , "
        // + CLNFMessage.nfmSubDate + " = '" + nfmSubDate + "' , "
        // + CLNFMessage.nfmCState + " = " + nfmCState + " , "
        // + CLNFMessage.nfmSubEnd + " = " + nfmSubEnd + " , "
        // + CLNFMessage.nfmSubEndDate + " = '" + nfmSubEndDate + "' , "
        // + CLNFMessage.nfmIsPuase + " = " + nfmIsPuase + " , "
        // + CLNFMessage.parReamrk + " = '" + parReamrk + "' where "
        // + CLNFMessage.nfmId + " = " + nfmId;

        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void alterNewFriendsData(Integer nfmId, Integer nfmSendId,
                                    Integer nfmGetId, Integer nfmCalendarId, Integer nfmOpenState,
                                    Integer nfmStatus, Integer nfmIsAlarm, Integer nfmPostpone,
                                    Integer nfmColorType, Integer nfmDisplayTime,
                                    Integer nfmBeforeTime, Integer nfmSourceType, Integer nfmType,
                                    Integer nfmAType, Integer nfmInSTable, Integer nfmIsEnd,
                                    Integer nfmDownState, Integer nfmPostState, String nfmParameter,
                                    String nfmContent, String nfmDate, String nfmTime,
                                    String nfmSourceDesc, String nfmSourceDescSpare, String nfmTags,
                                    String nfmRingDesc, String nfmRingCode, String nfmStartDate,
                                    String nfmInitialCreatedTime, String nfmLastCreatedTime,
                                    String nfmNextCreatedTime, String nfmWebURL, String nfmImagePath,
                                    String nfmSendName, String nfmRemark, Integer nfmUpdateState,
                                    Integer nfmPId, Integer nfmSubState, String nfmSubDate,
                                    Integer nfmCState, Integer nfmSubEnd, String nfmSubEndDate,
                                    Integer nfmIsPuase, String parReamrk, String nfmCreateTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmId + " = ?" + " , " + CLNFMessage.nfmSendId
                + " = ?" + " , " + CLNFMessage.nfmGetId + " = ?" + " , "
                + CLNFMessage.nfmCalendarId + " = ?" + " , "
                + CLNFMessage.nfmOpenState + " = ?" + " , "
                + CLNFMessage.nfmStatus + " = ?" + " , "
                + CLNFMessage.nfmIsAlarm + " = ?" + " , "
                + CLNFMessage.nfmPostpone + " = ?" + " , "
                + CLNFMessage.nfmColorType + " = ?" + " , "
                + CLNFMessage.nfmDisplayTime + " = ?" + " , "
                + CLNFMessage.nfmBeforeTime + " = ?" + " , "
                + CLNFMessage.nfmSourceType + " = ?" + " , "
                + CLNFMessage.nfmType + " = ?" + " , " + CLNFMessage.nfmAType
                + " = ?" + " , " + CLNFMessage.nfmInSTable + " = ?" + " , "
                + CLNFMessage.nfmIsEnd + " = ?" + " , "
                + CLNFMessage.nfmDownState + " = ?" + " , "
                + CLNFMessage.nfmPostState + " = ?" + " , "
                + CLNFMessage.nfmParameter + " = ?" + ", "
                + CLNFMessage.nfmContent + " = ?" + " , " + CLNFMessage.nfmDate
                + " = ?" + " , " + CLNFMessage.nfmTime + " = ?" + " , "
                + CLNFMessage.nfmSourceDesc + " = ?" + ", "
                + CLNFMessage.nfmSourceDescSpare + " = ?" + ", "
                + CLNFMessage.nfmTags + " = ?" + " , "
                + CLNFMessage.nfmRingDesc + " = ?" + " , "
                + CLNFMessage.nfmRingCode + " = ?" + ", "
                + CLNFMessage.nfmStartDate + " = ?" + " , "
                + CLNFMessage.nfmInitialCreatedTime + " = ?" + ", "
                + CLNFMessage.nfmLastCreatedTime + " = ?" + ", "
                + CLNFMessage.nfmNextCreatedTime + " = ?" + ", "
                + CLNFMessage.nfmWebURL + " = ?" + ", "
                + CLNFMessage.nfmImagePath + " = ?" + ", "
                + CLNFMessage.nfmSendName + " = ?" + ", "
                + CLNFMessage.nfmRemark + " = ?" + ", "
                + CLNFMessage.nfmUpdateState + " = ?" + ", "
                + CLNFMessage.nfmPId + " = ?" + ", " + CLNFMessage.nfmSubState
                + " = ?" + " , " + CLNFMessage.nfmSubDate + " = ?" + ", "
                + CLNFMessage.nfmCState + " = ?" + ", " + CLNFMessage.nfmSubEnd
                + " = ?" + ", " + CLNFMessage.nfmSubEndDate + " = ?" + ", "
                + CLNFMessage.nfmIsPuase + " = ?" + ", "
                + CLNFMessage.parReamrk + " = ?" + ", "
                + CLNFMessage.nfmCreateTime + " = ?" + " where "
                + CLNFMessage.nfmId + " = " + nfmId;
        Object[] mValue = new Object[]{nfmId, nfmSendId, nfmGetId,
                nfmCalendarId, nfmOpenState, nfmStatus, nfmIsAlarm,
                nfmPostpone, nfmColorType, nfmDisplayTime, nfmBeforeTime,
                nfmSourceType, nfmType, nfmAType, nfmInSTable, nfmIsEnd,
                nfmDownState, nfmPostState,
                StringUtils.getIsStringEqulesNull(nfmParameter),
                StringUtils.getIsStringEqulesNull(nfmContent),
                StringUtils.getIsStringEqulesNull(nfmDate),
                StringUtils.getIsStringEqulesNull(nfmTime),
                StringUtils.getIsStringEqulesNull(nfmSourceDesc),
                StringUtils.getIsStringEqulesNull(nfmSourceDescSpare),
                StringUtils.getIsStringEqulesNull(nfmTags),
                StringUtils.getIsStringEqulesNull(nfmRingDesc),
                StringUtils.getIsStringEqulesNull(nfmRingCode),
                StringUtils.getIsStringEqulesNull(nfmStartDate),
                StringUtils.getIsStringEqulesNull(nfmInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmLastCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmNextCreatedTime),
                StringUtils.getIsStringEqulesNull(nfmWebURL),
                StringUtils.getIsStringEqulesNull(nfmImagePath),
                StringUtils.getIsStringEqulesNull(nfmSendName),
                StringUtils.getIsStringEqulesNull(nfmRemark), nfmUpdateState,
                nfmPId, nfmSubState,
                StringUtils.getIsStringEqulesNull(nfmSubDate), nfmCState,
                nfmSubEnd, StringUtils.getIsStringEqulesNull(nfmSubEndDate),
                nfmIsPuase, StringUtils.getIsStringEqulesNull(parReamrk),
                StringUtils.getIsStringEqulesNull(nfmCreateTime)};
        // String sql = "update " + CLNFMessage.CLNFMessage + " set "
        // + CLNFMessage.nfmId + " = " + nfmId + " , "
        // + CLNFMessage.nfmSendId + " = " + nfmSendId + " , "
        // + CLNFMessage.nfmGetId + " = " + nfmGetId + " , "
        // + CLNFMessage.nfmCalendarId + " = " + nfmCalendarId + " , "
        // + CLNFMessage.nfmOpenState + " = " + nfmOpenState + " , "
        // + CLNFMessage.nfmStatus + " = " + nfmStatus + " , "
        // + CLNFMessage.nfmIsAlarm + " = " + nfmIsAlarm + " , "
        // + CLNFMessage.nfmPostpone + " = " + nfmPostpone + " , "
        // + CLNFMessage.nfmColorType + " = " + nfmColorType + " , "
        // + CLNFMessage.nfmDisplayTime + " = " + nfmDisplayTime + " , "
        // + CLNFMessage.nfmBeforeTime + " = " + nfmBeforeTime + " , "
        // + CLNFMessage.nfmSourceType + " = " + nfmSourceType + " , "
        // + CLNFMessage.nfmType + " = " + nfmType + " , "
        // + CLNFMessage.nfmAType + " = " + nfmAType + " , "
        // + CLNFMessage.nfmInSTable + " = " + nfmInSTable + " , "
        // + CLNFMessage.nfmIsEnd + " = " + nfmIsEnd + " , "
        // + CLNFMessage.nfmDownState + " = " + nfmDownState + " , "
        // + CLNFMessage.nfmPostState + " = " + nfmPostState + " , "
        // + CLNFMessage.nfmParameter + " = '" + nfmParameter + "' , "
        // + CLNFMessage.nfmContent + " = '" + nfmContent + "' , "
        // + CLNFMessage.nfmDate + " = '" + nfmDate + "' , "
        // + CLNFMessage.nfmTime + " = '" + nfmTime + "' , "
        // + CLNFMessage.nfmSourceDesc + " = '" + nfmSourceDesc + "' , "
        // + CLNFMessage.nfmSourceDescSpare + " = '" + nfmSourceDescSpare
        // + "' , " + CLNFMessage.nfmTags + " = '" + nfmTags + "' , "
        // + CLNFMessage.nfmRingDesc + " = '" + nfmRingDesc + "' , "
        // + CLNFMessage.nfmRingCode + " = '" + nfmRingCode + "' , "
        // + CLNFMessage.nfmStartDate + " = '" + nfmStartDate + "' , "
        // + CLNFMessage.nfmInitialCreatedTime + " = '"
        // + nfmInitialCreatedTime + "' , "
        // + CLNFMessage.nfmLastCreatedTime + " = '" + nfmLastCreatedTime
        // + "' , " + CLNFMessage.nfmNextCreatedTime + " = '"
        // + nfmNextCreatedTime + "' , " + CLNFMessage.nfmWebURL + " = '"
        // + nfmWebURL + "' , " + CLNFMessage.nfmImagePath + " = '"
        // + nfmImagePath + "' , " + CLNFMessage.nfmSendName + " ='"
        // + nfmSendName + "' , " + CLNFMessage.nfmRemark + " = '"
        // + nfmRemark + "' , " + CLNFMessage.nfmUpdateState + " = "
        // + nfmUpdateState + " , " + CLNFMessage.nfmPId + " = " + nfmPId
        // + " , " + CLNFMessage.nfmSubState + " = " + nfmSubState + " , "
        // + CLNFMessage.nfmSubDate + " = '" + nfmSubDate + "' , "
        // + CLNFMessage.nfmCState + " = " + nfmCState + " , "
        // + CLNFMessage.nfmSubEnd + " = " + nfmSubEnd + " , "
        // + CLNFMessage.nfmSubEndDate + " = '" + nfmSubEndDate + "' , "
        // + CLNFMessage.nfmIsPuase + " = " + nfmIsPuase + " , "
        // + CLNFMessage.parReamrk + " = '" + parReamrk + "' ,"
        // + CLNFMessage.nfmCreateTime + " = '" + nfmCreateTime
        // + "' where " + CLNFMessage.nfmId + " = " + nfmId;

        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据子记事的nfmid修改母记事状态
     */
    public void alterNewFriendParentData(Integer nfmPId, Integer nfmSubState,
                                         String nfmSubDate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmUpdateState + " = " + 2 + " , "
                + CLNFMessage.nfmSubState + " = " + 1 + " , "
                + CLNFMessage.nfmSubDate + " = '" + nfmSubDate + "' where "
                + CLNFMessage.nfmId + " = " + nfmPId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据子记事的nfmid修改母记事状态
     */
    public void alterNewFriendParentData1(Integer nfmPId, Integer nfmSubState,
                                          String nfmSubDate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmUpdateState + " = " + 2 + " , "
                + CLNFMessage.nfmSubState + " = " + nfmSubState + " , "
                + CLNFMessage.nfmSubDate + " = '" + nfmSubDate + "' where "
                + CLNFMessage.nfmId + " = " + nfmPId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据返回id删除本地发送消息
     */
    public void deleteNewFriendsData(Integer oldID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + CLNFMessage.CLNFMessage + " where "
                + CLNFMessage.nfmId + " = " + oldID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据返回id删除本地子记事
     */
    public void deleteNewFriendsChildData(Integer oldID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + CLNFMessage.CLNFMessage + " where "
                + CLNFMessage.nfmPId + " = " + oldID + " and ("
                + CLNFMessage.nfmSubState + " = " + 0 + " or "
                + CLNFMessage.nfmSubState + " = " + 3 + ")";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据返回id和uid删除本地记事
     */
    public void deleteFriendsData(Integer uid, Integer dataId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + CLNFMessage.CLNFMessage + " where "
                + CLNFMessage.nfmSendId + " = " + uid + " and "
                + CLNFMessage.nfmId + " = " + dataId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询数据库是否有相同id的数据
     */
    public int CheckCountNewFriendData(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + CLNFMessage.CLNFMessage
                + " where " + CLNFMessage.nfmId + " = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 根据nfmID删除对应的消息和重复消息的子记事
     *
     * @param nfmID
     */
    public void deleteNewFriendLocalData(Integer nfmID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (nfmID < 0) {
            sql = "delete from " + CLNFMessage.CLNFMessage + " where "
                    + CLNFMessage.nfmId + " = " + nfmID;
        } else {
            sql = "update " + CLNFMessage.CLNFMessage + " set "
                    + CLNFMessage.nfmUpdateState + " = " + 3 + " where "
                    + CLNFMessage.nfmId + " = " + nfmID + " and "
                    + CLNFMessage.nfmUpdateState + " != " + 3;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改新版好友消息子日程
     *
     * @return
     */
    public void updateNewFriendChildData(int nfmID, int nfmSubState,
                                         String nfmSubDate, int updateState) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmUpdateState + " = " + updateState + " , "
                + CLNFMessage.nfmSubState + " = " + nfmSubState + " , "
                + CLNFMessage.nfmSubDate + " = '" + nfmSubDate + "' where "
                + CLNFMessage.nfmId + " = " + nfmID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改新版好友顺延未结束日期
     *
     * @return
     */
    public void updateNewFriendChildData(int nfmID, String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmDate + " = '" + date + "' , "
                + CLNFMessage.nfmUpdateState + " = " + 2 + " where "
                + CLNFMessage.nfmId + " = " + nfmID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNewFriendChildData1(int nfmID, String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmDate + " = '" + date + "' , "
                + CLNFMessage.nfmUpdateState + " = " + 0 + " where "
                + CLNFMessage.nfmId + " = " + nfmID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改好友消息子记事结束状态和时间
     *
     * @return
     */
    public void updateNewFriendChildEndData(int nfmID, String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmDate + " = '" + date + "' where "
                + CLNFMessage.nfmId + " = " + nfmID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改新版好友信息是否结束
     *
     * @return
     */
    @SuppressWarnings("unchecked")
    public void updateNewFriendEndData(Map<String, String> upMap,
                                       String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + "="
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + "='"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String[] str = updateStr.split(",");
        String updateState = str[0].toString();
        String schIsEnd = str[1].toString();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + updateState + " , " + schIsEnd + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改新版好友信息是否结束 一个参数
     *
     * @return
     */
    @SuppressWarnings("unchecked")
    public void updateNewFriendEndData1(Map<String, String> upMap,
                                        String sqlWhere) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateMap = "";

        // 取出需修改的字段拼接
        Set set = upMap.entrySet();
        Iterator iterator = set.iterator();
        while (iterator.hasNext()) {
            Map.Entry mapentry = (Map.Entry) iterator.next();

            if (isNum(mapentry.getValue().toString())) {
                updateMap = updateMap + mapentry.getKey() + "="
                        + mapentry.getValue() + ",";
            } else {
                updateMap = updateMap + mapentry.getKey() + "='"
                        + mapentry.getValue() + "',";
            }

        }
        String updateStr = updateMap.substring(0, updateMap.lastIndexOf(","));
        String[] str = updateStr.split(",");
        String updateState = str[0].toString();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + updateState + " " + sqlWhere;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 更改好友日程推迟时间
     */
    public void updateNewFriendDateData(int ID, String date, String time,
                                        int updatestate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmDate + " = '" + date + "', "
                + CLNFMessage.nfmTime + " = '" + time + "', "
                + CLNFMessage.nfmUpdateState + " = " + updatestate + " where "
                + CLNFMessage.nfmId + " = " + ID + " and "
                + CLNFMessage.nfmUpdateState + " != " + 3;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改好友消息子记事状态和修改时间
     *
     * @return
     */
    public void updateNewFriendChildStateData(int nfmID, int state, String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLNFMessage.CLNFMessage + " set "
                + CLNFMessage.nfmSubState + " = " + state + " , "
                + CLNFMessage.nfmSubDate + " = '" + date + "' where "
                + CLNFMessage.nfmId + " = " + nfmID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /************************************* 标签表 *************************************************/
    /**
     * 本地插入
     *
     * @param ctgText
     * @param ctgOrder
     * @param ctgColor
     * @param ctgType
     * @param ctgUpdateState
     * @param ctgDesc
     * @param ctgCount
     * @return
     */
    public boolean insertTagData(String ctgText, Integer ctgOrder,
                                 String ctgColor, Integer ctgType, Integer ctgUpdateState,
                                 String ctgDesc, String ctgCount) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int ctgId = getLocalId(-1, "CLCategoryTable", CLCategoryTable.ctgId);
        // String sql = "insert into CLCategoryTable values(" + ctgId + ",'"
        // + ctgText + "'," + ctgOrder + ",'" + ctgColor + "'," + ctgType
        // + "," + ctgUpdateState + ",'" + ctgDesc + "','" + ctgCount
        // + "')";
        String sql = "insert into CLCategoryTable(ctgId,ctgType,ctgOrder,ctgUpdateState,"
                + "ctgText,ctgColor,ctgDesc,ctgCount) "
                + "values(?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ctgId, ctgType, ctgOrder, ctgUpdateState,
                StringUtils.getIsStringEqulesNull(ctgText),
                StringUtils.getIsStringEqulesNull(ctgColor),
                StringUtils.getIsStringEqulesNull(ctgDesc),
                StringUtils.getIsStringEqulesNull(ctgCount)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 从网上获取
     *
     * @return
     */
    public boolean insertTagIntenetData(Integer ctgId, String ctgText,
                                        Integer ctgOrder, String ctgColor, Integer ctgType,
                                        Integer ctgUpdateState, String ctgDesc, String ctgCount) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        // String sql = "insert into CLCategoryTable values(" + ctgId + ",'"
        // + ctgText + "'," + ctgOrder + ",'" + ctgColor + "'," + ctgType
        // + "," + ctgUpdateState + ",'" + ctgDesc + "','" + ctgCount
        // + "')";
        String sql = "replace into CLCategoryTable(ctgId,ctgType,ctgOrder,ctgUpdateState,"
                + "ctgText,ctgColor,ctgDesc,ctgCount) "
                + "values(?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{ctgId, ctgType, ctgOrder, ctgUpdateState,
                StringUtils.getIsStringEqulesNull(ctgText),
                StringUtils.getIsStringEqulesNull(ctgColor),
                StringUtils.getIsStringEqulesNull(ctgDesc),
                StringUtils.getIsStringEqulesNull(ctgCount)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 查询数据库是否有标签
     */
    public int CheckCountTagData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + CLCategoryTable.CLCategoryTable
                + " where " + CLCategoryTable.ctgId + " > " + 0 + " and "
                + CLCategoryTable.ctgType + " = " + 1;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 查询数据库是否有标签
     */
    public int CheckCountTagData(int ctgId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + CLCategoryTable.CLCategoryTable
                + " where " + CLCategoryTable.ctgId + " = " + ctgId;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    public void updateTagName(int id, String name) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                + CLCategoryTable.ctgText + " = '" + name + "' , "
                + CLCategoryTable.ctgUpdateState + " = 2 where "
                + CLCategoryTable.ctgId + " = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateTagData(String ctgId, String ctgText, String ctgOrder,
                              String ctgColor, String ctgType, Integer ctgUpdateState,
                              String ctgDesc, String ctgCount) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                + CLCategoryTable.ctgText + " = ?" + ", "
                + CLCategoryTable.ctgOrder + " = ?" + " , "
                + CLCategoryTable.ctgColor + " = ?" + ", "
                + CLCategoryTable.ctgType + " = ?" + ", "
                + CLCategoryTable.ctgUpdateState + " = ?" + ", "
                + CLCategoryTable.ctgDesc + " = ?" + ", "
                + CLCategoryTable.ctgCount + " = ?" + " where "
                + CLCategoryTable.ctgId + " = " + ctgId;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(ctgText), ctgOrder,
                StringUtils.getIsStringEqulesNull(ctgColor), ctgType,
                ctgUpdateState, StringUtils.getIsStringEqulesNull(ctgDesc),
                StringUtils.getIsStringEqulesNull(ctgCount)};
        // String sql = "update " + CLCategoryTable.CLCategoryTable + " set "
        // + CLCategoryTable.ctgText + " = '" + ctgText + "' , "
        // + CLCategoryTable.ctgOrder + " = " + ctgOrder + " , "
        // + CLCategoryTable.ctgColor + " = '" + ctgColor + "', "
        // + CLCategoryTable.ctgType + " = " + ctgType + ", "
        // + CLCategoryTable.ctgUpdateState + " = " + ctgUpdateState
        // + ", " + CLCategoryTable.ctgDesc + " = '" + ctgDesc + "', "
        // + CLCategoryTable.ctgCount + " = '" + ctgCount + "' where "
        // + CLCategoryTable.ctgId + " = " + ctgId;
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteTagData(Integer ctgId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (ctgId < 0) {
            sql = "delete from " + CLCategoryTable.CLCategoryTable + " where "
                    + CLCategoryTable.ctgId + " = " + ctgId;
        } else {
            sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                    + CLCategoryTable.ctgUpdateState + " = " + 3 + " where "
                    + CLCategoryTable.ctgId + " = " + ctgId + " and "
                    + CLCategoryTable.ctgUpdateState + " != " + 3;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public List<TagCommandBean> QueryTagData(int type) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<TagCommandBean> dataList = new ArrayList<TagCommandBean>();
        TagCommandBean noticeMap = null;
        String sql = "";
        switch (type) {
            case 10:
                sql = "select * from CLCategoryTable group by ctgText order by ctgOrder";
                break;
            case 11:
                sql = "select * from CLCategoryTable where ctgId != 101 group by ctgText order by ctgOrder";
                break;
            case -1:
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgType + " = " + 1
                        + " and " + CLCategoryTable.ctgDesc + " != ''"
                        + " order by ctgOrder asc";
                break;
            case -3:
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                        + " and " + CLCategoryTable.ctgId + " < " + 103
                        + " order by ctgOrder asc";
                break;
            case -4:
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                        + " and " + CLCategoryTable.ctgId + " > " + 199
                        + " order by ctgId asc limit 0,3 ";
                break;
            case -5:
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                        + " order by ctgOrder asc";
                break;
            case 0:// 查询标签所有未删除的数据
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
//                        + " and " + CLCategoryTable.ctgType + " = " + 0
                        + " and " + CLCategoryTable.ctgId + " > " + 199
                        + " order by ctgOrder asc";
                break;
            case -2:
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                        + " and " + CLCategoryTable.ctgId + " > " + 199
                        + " order by ctgOrder asc";
                break;
            case 1:// 新建
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " = " + 1
                        + " and " + CLCategoryTable.ctgType + " != " + 0
                        + " order by ctgOrder asc";
                break;
            case 2:// 修改
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " = " + 2
                        + " and " + CLCategoryTable.ctgType + " != " + 0
                        + " order by ctgOrder asc";
                break;
            case 3:// 删除
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " = " + 3
                        + " and " + CLCategoryTable.ctgType + " != " + 0
                        + " order by ctgOrder asc";
                break;
            case 4:// 不查询id为1和2的数据 1为生日 2为到期日
                sql = "select * from " + CLCategoryTable.CLCategoryTable
                        + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                        + " and " + CLCategoryTable.ctgType + " != " + 0
                        + " and " + CLCategoryTable.ctgId + " > " + 199
                        + " and ctgId < 0 order by ctgOrder asc";
                break;
            default:
                break;
        }

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new TagCommandBean();
                noticeMap.setCtgId(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgId)));
                noticeMap.setCtgType(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgType)));
                noticeMap.setCtgOrder(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgOrder)));
                noticeMap.setCtgUpdateState(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgUpdateState)));
                noticeMap.setCtgText(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgText)));
                noticeMap.setCtgColor(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgColor)));
                noticeMap.setCtgDesc(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgDesc)));
                noticeMap.setCtgCount(cursor.getString(cursor
                        .getColumnIndex(CLCategoryTable.ctgCount)));
                dataList.add(noticeMap);

            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    public Map<String, String> QueryTagNameData(int colorType) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + CLCategoryTable.CLCategoryTable
                + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                + " and (" + CLCategoryTable.ctgId + " = " + colorType + " or ctgDesc = '" + colorType + "' ) group by ctgDesc order by ctgDesc asc";

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (cursor.getCount() > 0) {
                if (cursor.moveToNext()) {
                    noticeMap = new HashMap<String, String>();
                    noticeMap.put(CLCategoryTable.ctgId, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgId)));
                    noticeMap.put(CLCategoryTable.ctgType, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgType)));
                    noticeMap.put(CLCategoryTable.ctgOrder, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgOrder)));
                    noticeMap
                            .put(CLCategoryTable.ctgUpdateState,
                                    cursor.getString(cursor
                                            .getColumnIndex(CLCategoryTable.ctgUpdateState)));
                    noticeMap.put(CLCategoryTable.ctgText, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgText)));
                    noticeMap.put(CLCategoryTable.ctgColor, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgColor)));
                    noticeMap.put(CLCategoryTable.ctgDesc, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgDesc)));
                    noticeMap.put(CLCategoryTable.ctgCount, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgCount)));
                    return noticeMap;
                }
            } else {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLCategoryTable.ctgText, "未分类");
                return noticeMap;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    public Map<String, String> QueryTagIDData(String tagname) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = null;
        String sql = "select * from " + CLCategoryTable.CLCategoryTable
                + " where " + CLCategoryTable.ctgUpdateState + " != " + 3
                + " and " + CLCategoryTable.ctgText + " = '" + tagname
                + "' order by ctgOrder asc";

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (cursor.getCount() > 0) {
                if (cursor.moveToNext()) {
                    noticeMap = new HashMap<String, String>();
                    noticeMap.put(CLCategoryTable.ctgId, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgId)));
                    noticeMap.put(CLCategoryTable.ctgType, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgType)));
                    noticeMap.put(CLCategoryTable.ctgOrder, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgOrder)));
                    noticeMap
                            .put(CLCategoryTable.ctgUpdateState,
                                    cursor.getString(cursor
                                            .getColumnIndex(CLCategoryTable.ctgUpdateState)));
                    noticeMap.put(CLCategoryTable.ctgText, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgText)));
                    noticeMap.put(CLCategoryTable.ctgColor, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgColor)));
                    noticeMap.put(CLCategoryTable.ctgDesc, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgDesc)));
                    noticeMap.put(CLCategoryTable.ctgCount, cursor
                            .getString(cursor
                                    .getColumnIndex(CLCategoryTable.ctgCount)));
                    return noticeMap;
                }
            } else {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLCategoryTable.ctgText, "未分类");
                noticeMap.put(CLCategoryTable.ctgId, "0");
                return noticeMap;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    /**
     * 修改排序顺序
     */
    public void updateTagOrderData(Integer ctgId, Integer ctgOrder) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "";
        if (ctgId < 0) {
            sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                    + CLCategoryTable.ctgOrder + " = " + ctgOrder + " , "
                    + CLCategoryTable.ctgUpdateState + " = " + 1 + " where "
                    + CLCategoryTable.ctgId + " = " + ctgId;
        } else {
            sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                    + CLCategoryTable.ctgOrder + " = " + ctgOrder + " , "
                    + CLCategoryTable.ctgUpdateState + " = " + 2 + " where "
                    + CLCategoryTable.ctgId + " = " + ctgId;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 和网上进行同步修改id
     */
    public void updateTagIDs(Integer desid, Integer newCtgId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                + CLCategoryTable.ctgId + " = " + newCtgId + " , "
                + CLCategoryTable.ctgUpdateState + " = " + 0 + " where "
                + CLCategoryTable.ctgDesc + " = '" + desid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateTagID(Integer ctgId, Integer newCtgId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLCategoryTable.CLCategoryTable + " set "
                + CLCategoryTable.ctgId + " = " + newCtgId + " , "
                + CLCategoryTable.ctgUpdateState + " = " + 0 + " where "
                + CLCategoryTable.ctgId + " = '" + ctgId + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /********************************************* 签到表 **************************************************/
    /**
     * 插入签到表
     */
    public boolean insertQianDaoData(Integer adsId, Integer adsScore,
                                     String adsDate, String adsLDate, String adsHoliday,
                                     String adsLHoliday, String adsSolarTerms, String adsImageNo,
                                     String adsImagePath, String adsWebURL) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        // String sql = "insert into CLAdsTable values(" + adsId + "," +
        // adsScore
        // + ",'" + adsDate + "','" + adsLDate + "','" + adsHoliday
        // + "','" + adsLHoliday + "','" + adsSolarTerms + "','"
        // + adsImageNo + "','" + adsImagePath + "','" + adsWebURL + "')";
        String sql = "insert into CLAdsTable(adsId,adsScore,adsDate,adsLDate,"
                + "adsHoliday,adsLHoliday,adsSolarTerms,adsImageNo,adsImagePath,adsWebURL) "
                + "values(?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{adsId, adsScore,
                StringUtils.getIsStringEqulesNull(adsDate),
                StringUtils.getIsStringEqulesNull(adsLDate),
                StringUtils.getIsStringEqulesNull(adsHoliday),
                StringUtils.getIsStringEqulesNull(adsLHoliday),
                StringUtils.getIsStringEqulesNull(adsSolarTerms),
                StringUtils.getIsStringEqulesNull(adsImageNo),
                StringUtils.getIsStringEqulesNull(adsImagePath),
                StringUtils.getIsStringEqulesNull(adsWebURL)};
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }


    /**
     * 获取当日积分
     *
     * @return
     */
    public String todayJifen() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from CLAdsTable where adsDate = '" + DateUtil.formatDate(new Date()) + "'";
        String jifen = "0";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                jifen = cursor.getString(cursor.getColumnIndex("adsScore"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
            jifen = "0";
        }

        return jifen;
    }

    public void updateQianDaoData(Integer adsId, Integer adsScore,
                                  String adsDate, String adsLDate, String adsHoliday,
                                  String adsLHoliday, String adsSolarTerms, String adsImageNo,
                                  String adsImagePath, String adsWebURL) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLAdsTable.CLAdsTable + " set "
                + CLAdsTable.adsScore + " = ?" + ", " + CLAdsTable.adsDate
                + " = ?" + ", " + CLAdsTable.adsLDate + " = ?" + ", "
                + CLAdsTable.adsHoliday + " = ?" + ", "
                + CLAdsTable.adsLHoliday + " = ?" + ", "
                + CLAdsTable.adsSolarTerms + " = ?" + ", "
                + CLAdsTable.adsImageNo + " = ?" + ", "
                + CLAdsTable.adsImagePath + " = ?" + ", "
                + CLAdsTable.adsWebURL + " = ?" + " where " + CLAdsTable.adsId
                + " = " + adsId;
        Object[] mValue = new Object[]{adsScore,
                StringUtils.getIsStringEqulesNull(adsDate),
                StringUtils.getIsStringEqulesNull(adsLDate),
                StringUtils.getIsStringEqulesNull(adsHoliday),
                StringUtils.getIsStringEqulesNull(adsLHoliday),
                StringUtils.getIsStringEqulesNull(adsSolarTerms),
                StringUtils.getIsStringEqulesNull(adsImageNo),
                StringUtils.getIsStringEqulesNull(adsImagePath),
                StringUtils.getIsStringEqulesNull(adsWebURL)};
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public String getQiaodaoImageDate(String imagename) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select adsDate from CLAdsTable where adsImageNo = '" + imagename.replace("\\", "") + "'";
        String date = DateUtil.formatDate(new Date());
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                date = cursor.getColumnName(cursor.getColumnIndex("adsDate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
            date = DateUtil.formatDate(new Date());
        }

        return date;
    }

    /**
     * 修改对应的图片信息
     */
    public void updateQianDaoImgData(String adsImageNo, String adsImagePath,
                                     String adsWebURL) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update CLAdsTable set adsImagePath = '" + adsImagePath + "' where adsImageNo = '" + adsImageNo + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询数据库是否有标签
     */
    public int CheckCountQianDaoData(String adsDate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + CLAdsTable.CLAdsTable
                + " where " + CLAdsTable.adsDate + " = '" + adsDate + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;

    }

    /**
     * 查询数据库是否有图片相应信息
     */
    public int CheckCountQianDaoImgData(String adsImageNo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + CLAdsTable.CLAdsTable
                + " where " + CLAdsTable.adsImageNo + " = '" + adsImageNo + "'";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    public Map<String, String> QueryQianDaoImgData(String date, int type) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        Map<String, String> noticeMap = new HashMap<String, String>();
        String sql = "";
        switch (type) {
            case 0:// 根据日期查询是否含有图片
                sql = "select * from " + CLAdsTable.CLAdsTable + " where "
                        + CLAdsTable.adsDate + " = '" + date
                        + "' order by adsDate desc";
                break;
            case 1:

                break;
            default:
                break;
        }

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap.put(CLAdsTable.adsId, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsId)));
                noticeMap.put(CLAdsTable.adsScore, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsScore)));
                noticeMap.put(CLAdsTable.adsDate, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsDate)));
                noticeMap.put(CLAdsTable.adsLDate, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsLDate)));
                noticeMap.put(CLAdsTable.adsHoliday, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsHoliday)));
                noticeMap.put(CLAdsTable.adsLHoliday, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsLHoliday)));
                noticeMap.put(CLAdsTable.adsSolarTerms, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsSolarTerms)));
                noticeMap.put(CLAdsTable.adsImageNo, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsImageNo)));
                noticeMap.put(CLAdsTable.adsImagePath, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsImagePath)));
                noticeMap.put(CLAdsTable.adsWebURL, cursor.getString(cursor
                        .getColumnIndex(CLAdsTable.adsWebURL)));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    /**
     * 删除标签
     */
    public void deleteCLAdsTable() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + CLAdsTable.CLAdsTable;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    // ====================================新版发现相关数据操作======================================//

    /**
     * 删除日程表中schaid相同的日程
     */
    public void deleteSchAIDData(int schcRecommendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schcRecommendId + " = " + schcRecommendId
                + " and " + ScheduleTable.schAID + " != " + 0;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除重复母记事
     */
    public void deleteRepFocusParentData(int repId, int recommandId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schRepeatID + " = " + repId + " and "
                + ScheduleTable.schAID + " != " + 0 + " and "
                + ScheduleTable.schcRecommendId + " = " + recommandId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除重复子记事
     */
    public void deleteRepFocusData(int repId, String repdatetwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schRepeatID + " = " + repId + " and "
                + ScheduleTable.schAID + " != " + 0 + " and "
                + ScheduleTable.schRepeatDate + " = '" + repdatetwo + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除普通记事
     */
    public void deleteSchFocusData(int schAID, int recommandId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schAID + " = " + schAID + " and "
                + ScheduleTable.schAID + " > " + 0 + " and "
                + ScheduleTable.schcRecommendId + " = " + recommandId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询日程表中repid为0并且schaid!=0并且schaid和传入发现中schaid有没有相同的
     */
    public int CheckCountSchFromFocusData(int schAID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schAID + " = " + schAID + " and "
                + ScheduleTable.schAID + " > " + 0;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    /**
     * 查询日程表中repid不为为0并且schaid!=0并且repid和传入发现中repid有没有相同的
     */
    public int CheckCountRepFromFocusData(int repid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "select count(*) from " + ScheduleTable.ScheduleTable
                + " where " + ScheduleTable.schRepeatID + " = " + repid
                + " and " + ScheduleTable.schAID + " > " + 0;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    public void updateScheduleNoIDForSchData(String schContent, String schDate,
                                             String schTime, int schIsAlarm, int schBeforeTime,
                                             int schDisplayTime, int schIsPostpone, int schIsImportant,
                                             int schColorType, int schIsEnd, String createtime, String schTags,
                                             int schSourceType, String schSourceDesc, String schSourceDescSpare,
                                             int schRepeatID, String schRepeatDate, String schUpdateTime,
                                             int schUpdateState, int schOpenState, int schRepeatLink,
                                             String schRingDesc, String schRingCode, String schcRecommendName,
                                             int schRead, int schAID, int schAType, String schWebURL,
                                             String schImagePath, int schFocusState, int schFriendID,
                                             int schcRecommendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "update ScheduleTable set " + ScheduleTable.schContent
                + " = ?" + "," + ScheduleTable.schDate + " = ? " + ", "
                + ScheduleTable.schTime + " = ?" + ", "
                + ScheduleTable.schIsAlarm + " = ?" + ", "
                + ScheduleTable.schBeforeTime + " = ?" + ", "
                + ScheduleTable.schDisplayTime + " = ?" + ", "
                + ScheduleTable.schIsPostpone + " = ?" + ", "
                + ScheduleTable.schIsImportant + " = ?" + ", "
                + ScheduleTable.schColorType + " = ?" + ", "
                + ScheduleTable.schIsEnd + " = ?" + ", "
                + ScheduleTable.schTags + " = ?" + ", "
                + ScheduleTable.schSourceType + " = ?" + ", "
                + ScheduleTable.schSourceDesc + " = ?" + ", "
                + ScheduleTable.schSourceDescSpare + " = ?" + ", "
                + ScheduleTable.schRepeatID + " = ?" + ", "
                + ScheduleTable.schRepeatDate + " = ?" + ", "
                + ScheduleTable.schUpdateTime + " = ?" + ", "
                + ScheduleTable.schUpdateState + " = ?" + ", "
                + ScheduleTable.schOpenState + " = ?" + ", "
                + ScheduleTable.schRepeatLink + " = ?" + ", "
                + ScheduleTable.schRingDesc + " = ?" + ", "
                + ScheduleTable.schRingCode + " = ?" + ", "
                + ScheduleTable.schcRecommendName + " = ?" + ", "
                + ScheduleTable.schRead + " = ?" + ", " + ScheduleTable.schAID
                + " = ?" + ", " + ScheduleTable.schAType + " = ?" + ", "
                + ScheduleTable.schWebURL + " = ?" + ", "
                + ScheduleTable.schImagePath + " = ?" + ", "
                + ScheduleTable.schFocusState + " = ?" + ", "
                + ScheduleTable.schFriendID + " = ?" + ", "
                + ScheduleTable.schcRecommendId + " = ? " + " where "
                + ScheduleTable.schAID + " = " + schAID;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId};
        // String sql = "update " + ScheduleTable.ScheduleTable + " set "
        // + ScheduleTable.schContent + " = '" + content + "', "
        // + ScheduleTable.schDate + " = '" + schDate + "', "
        // + ScheduleTable.schTime + " = '" + schTime + "', "
        // + ScheduleTable.schIsAlarm + " = " + schIsAlarm + ", "
        // + ScheduleTable.schBeforeTime + " = " + schBeforeTime + ", "
        // + ScheduleTable.schDisplayTime + " = " + schDisplayTime + ", "
        // + ScheduleTable.schIsPostpone + " = " + schIsPostpone + ", "
        // + ScheduleTable.schIsImportant + " = " + schIsImportant + ", "
        // + ScheduleTable.schColorType + " = " + schColorType + ", "
        // + ScheduleTable.schIsEnd + " = " + schIsEnd + ", "
        // + ScheduleTable.schCreateTime + " = '" + createtime + "', "
        // + ScheduleTable.schTags + " = '" + schTags + "', "
        // + ScheduleTable.schSourceType + " = '" + schSourceType + "', "
        // + ScheduleTable.schSourceDesc + " = '" + schSourceDesc + "', "
        // + ScheduleTable.schSourceDescSpare + " ='"
        // + schSourceDescSpare + "', " + ScheduleTable.schRepeatID
        // + " = " + schRepeatID + ", " + ScheduleTable.schRepeatDate
        // + " = '" + schRepeatDate + "', " + ScheduleTable.schUpdateTime
        // + " = '" + schUpdateTime + "', " + ScheduleTable.schUpdateState
        // + " = " + schUpdateState + ", " + ScheduleTable.schOpenState
        // + " = " + schOpenState + ", " + ScheduleTable.schRepeatLink
        // + " = " + schRepeatLink + ", " + ScheduleTable.schRingDesc
        // + " = '" + schRingDesc + "', " + ScheduleTable.schRingCode
        // + " = '" + schRingCode + "', "
        // + ScheduleTable.schcRecommendName + " = '" + schcRecommendName
        // + "', " + ScheduleTable.schRead + " = " + schRead + ", "
        // + ScheduleTable.schAID + " = " + schAID + ", "
        // + ScheduleTable.schAType + " = " + schAType + ", "
        // + ScheduleTable.schWebURL + " = '" + schWebURL + "', "
        // + ScheduleTable.schImagePath + " = '" + schImagePath + "', "
        // + ScheduleTable.schFocusState + " = " + schFocusState + ", "
        // + ScheduleTable.schFriendID + " = " + schFriendID + ", "
        // + ScheduleTable.schcRecommendId + " = " + schcRecommendId
        // + " where " + ScheduleTable.schAID + " = " + schAID;
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateScheduleNoIDForRepData(String schContent, String schDate,
                                             String schTime, int schIsAlarm, int schBeforeTime,
                                             int schDisplayTime, int schIsPostpone, int schIsImportant,
                                             int schColorType, int schIsEnd, String createtime, String schTags,
                                             int schSourceType, String schSourceDesc, String schSourceDescSpare,
                                             int schRepeatID, String schRepeatDate, String schUpdateTime,
                                             int schUpdateState, int schOpenState, int schRepeatLink,
                                             String schRingDesc, String schRingCode, String schcRecommendName,
                                             int schRead, int schAID, int schAType, String schWebURL,
                                             String schImagePath, int schFocusState, int schFriendID,
                                             int schcRecommendId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = schContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "update ScheduleTable set " + ScheduleTable.schContent
                + " = ?" + "," + ScheduleTable.schDate + " = ? " + ", "
                + ScheduleTable.schTime + " = ?" + ", "
                + ScheduleTable.schIsAlarm + " = ?" + ", "
                + ScheduleTable.schBeforeTime + " = ?" + ", "
                + ScheduleTable.schDisplayTime + " = ?" + ", "
                + ScheduleTable.schIsPostpone + " = ?" + ", "
                + ScheduleTable.schIsImportant + " = ?" + ", "
                + ScheduleTable.schColorType + " = ?" + ", "
                + ScheduleTable.schIsEnd + " = ?" + ", "
                + ScheduleTable.schCreateTime + " = ?" + ", "
                + ScheduleTable.schTags + " = ?" + ", "
                + ScheduleTable.schSourceType + " = ?" + ", "
                + ScheduleTable.schSourceDesc + " = ?" + ", "
                + ScheduleTable.schSourceDescSpare + " = ?" + ", "
                + ScheduleTable.schRepeatID + " = ?" + ", "
                + ScheduleTable.schRepeatDate + " = ?" + ", "
                + ScheduleTable.schUpdateTime + " = ?" + ", "
                + ScheduleTable.schUpdateState + " = ?" + ", "
                + ScheduleTable.schOpenState + " = ?" + ", "
                + ScheduleTable.schRepeatLink + " = ?" + ", "
                + ScheduleTable.schRingDesc + " = ?" + ", "
                + ScheduleTable.schRingCode + " = ?" + ", "
                + ScheduleTable.schcRecommendName + " = ?" + ", "
                + ScheduleTable.schRead + " = ?" + ", " + ScheduleTable.schAID
                + " = ?" + ", " + ScheduleTable.schAType + " = ?" + ", "
                + ScheduleTable.schWebURL + " = ?" + ", "
                + ScheduleTable.schImagePath + " = ?" + ", "
                + ScheduleTable.schFocusState + " = ?" + ", "
                + ScheduleTable.schFriendID + " = ?" + ", "
                + ScheduleTable.schcRecommendId + " = ? " + " where "
                + ScheduleTable.schRepeatID + " = " + schRepeatID;
        Object[] mValue = new Object[]{
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(schDate),
                StringUtils.getIsStringEqulesNull(schTime), schIsAlarm,
                schBeforeTime, schDisplayTime, schIsPostpone, schIsImportant,
                schColorType, schIsEnd,
                StringUtils.getIsStringEqulesNull(createtime),
                StringUtils.getIsStringEqulesNull(schTags), schSourceType,
                StringUtils.getIsStringEqulesNull(schSourceDesc),
                StringUtils.getIsStringEqulesNull(schSourceDescSpare),
                schRepeatID, StringUtils.getIsStringEqulesNull(schRepeatDate),
                StringUtils.getIsStringEqulesNull(schUpdateTime),
                schUpdateState, schOpenState, schRepeatLink,
                StringUtils.getIsStringEqulesNull(schRingDesc),
                StringUtils.getIsStringEqulesNull(schRingCode),
                StringUtils.getIsStringEqulesNull(schcRecommendName), schRead,
                schAID, schAType, StringUtils.getIsStringEqulesNull(schWebURL),
                StringUtils.getIsStringEqulesNull(schImagePath), schFocusState,
                schFriendID, schcRecommendId};
        // String sql = "update " + ScheduleTable.ScheduleTable + " set "
        // + ScheduleTable.schContent + " = '" + content + "', "
        // + ScheduleTable.schDate + " = '" + schDate + "', "
        // + ScheduleTable.schTime + " = '" + schTime + "', "
        // + ScheduleTable.schIsAlarm + " = " + schIsAlarm + ", "
        // + ScheduleTable.schBeforeTime + " = " + schBeforeTime + ", "
        // + ScheduleTable.schDisplayTime + " = " + schDisplayTime + ", "
        // + ScheduleTable.schIsPostpone + " = " + schIsPostpone + ", "
        // + ScheduleTable.schIsImportant + " = " + schIsImportant + ", "
        // + ScheduleTable.schColorType + " = " + schColorType + ", "
        // + ScheduleTable.schIsEnd + " = " + schIsEnd + ", "
        // + ScheduleTable.schCreateTime + " = '" + createtime + "', "
        // + ScheduleTable.schTags + " = '" + schTags + "', "
        // + ScheduleTable.schSourceType + " = '" + schSourceType + "', "
        // + ScheduleTable.schSourceDesc + " = '" + schSourceDesc + "', "
        // + ScheduleTable.schSourceDescSpare + " = '"
        // + schSourceDescSpare + "', " + ScheduleTable.schRepeatID
        // + " = " + schRepeatID + ", " + ScheduleTable.schRepeatDate
        // + " = '" + schRepeatDate + "', " + ScheduleTable.schUpdateTime
        // + " = '" + schUpdateTime + "', " + ScheduleTable.schUpdateState
        // + " = " + schUpdateState + ", " + ScheduleTable.schOpenState
        // + " = " + schOpenState + ", " + ScheduleTable.schRepeatLink
        // + " = " + schRepeatLink + ", " + ScheduleTable.schRingDesc
        // + " = '" + schRingDesc + "', " + ScheduleTable.schRingCode
        // + " = '" + schRingCode + "', "
        // + ScheduleTable.schcRecommendName + " = '" + schcRecommendName
        // + "', " + ScheduleTable.schRead + " = " + schRead + ", "
        // + ScheduleTable.schAID + " = " + schAID + ", "
        // + ScheduleTable.schAType + " = " + schAType + ", "
        // + ScheduleTable.schWebURL + " = '" + schWebURL + "', "
        // + ScheduleTable.schImagePath + " = '" + schImagePath + "', "
        // + ScheduleTable.schFocusState + " = " + schFocusState + ", "
        // + ScheduleTable.schFriendID + " = " + schFriendID + ", "
        // + ScheduleTable.schcRecommendId + " = " + schcRecommendId
        // + " where " + ScheduleTable.schRepeatID + " = " + schRepeatID;
        try {
            sqldb.execSQL(sql, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 插入新版发现分享表
     *
     * @return
     */
    public boolean insertNewFocusData(Integer fstFID, Integer fstType,
                                      Integer fstBeforeTime, Integer fstIsAlarm, Integer fstDisplayTime,
                                      Integer fstColorType, Integer fstIsPostpone,
                                      Integer fstIsImportant, Integer fstIsEnd, Integer fstSourceType,
                                      Integer fstRepeatId, Integer fstOpenState, Integer fstRepeatLink,
                                      Integer fstRecommendId, Integer fstIsRead, Integer fstAID,
                                      Integer fstIsPuase, Integer fstRepStateOne, Integer fstRepStateTwo,
                                      Integer fstRepInStable, Integer fstPostState, Integer fstRepType,
                                      Integer fstAType, Integer fstUpdateState, String fstParameter,
                                      String fstContent, String fstDate, String fstTime,
                                      String fstRingCode, String fstRingDesc, String fstTags,
                                      String fstSourceDesc, String fstSourceDescSpare,
                                      String fstRepeatDate, String fstRepStartDate,
                                      String fstRpNextCreatedTime, String fstRepLastCreatedTime,
                                      String fstRepInitialCreatedTime, String fstRepDateOne,
                                      String fstRepDateTwo, String fstRecommendName, String fstWebURL,
                                      String fstImagePath, String fstParReamrk, String fstCreateTime,
                                      String fstUpdateTime, String fstReamrk1, String fstReamrk2,
                                      String fstReamrk3, String fstReamrk4, String fstReamrk5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int fstID = getLocalId(1, "CLFindScheduleTable",
                CLFindScheduleTable.fstID);
        int fstSchID = getLocalId(-1, "CLFindScheduleTable",
                CLFindScheduleTable.fstSchID);
        String content = fstContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");

        String insertStr = "insert into CLFindScheduleTable(fstID,fstFID,fstSchID, fstType,"
                + "fstBeforeTime, fstIsAlarm, fstDisplayTime,fstColorType, fstIsPostpone,"
                + "fstIsImportant,fstIsEnd, fstSourceType,fstRepeatId, fstOpenState, "
                + "fstRepeatLink,fstRecommendId, fstIsRead, fstAID,fstIsPuase, fstRepStateOne,"
                + "fstRepStateTwo,fstRepInStable,fstPostState, fstRepType,fstAType, "
                + "fstUpdateState, fstParameter,fstContent, fstDate, fstTime,fstRingCode,"
                + " fstRingDesc, fstTags,fstSourceDesc, fstSourceDescSpare,fstRepeatDate,"
                + " fstRepStartDate,fstRpNextCreatedTime, fstRepLastCreatedTime,"
                + "fstRepInitialCreatedTime, fstRepDateOne,fstRepDateTwo, fstRecommendName,"
                + " fstWebURL,fstImagePath,fstParReamrk, fstCreateTime,fstUpdateTime, "
                + "fstReamrk1,fstReamrk2,fstReamrk3, fstReamrk4,fstReamrk5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{fstID, fstFID, fstSchID, fstType,
                fstBeforeTime, fstIsAlarm, fstDisplayTime, fstColorType,
                fstIsPostpone, fstIsImportant, fstIsEnd, fstSourceType,
                fstRepeatId, fstOpenState, fstRepeatLink, fstRecommendId,
                fstIsRead, fstAID, fstIsPuase, fstRepStateOne, fstRepStateTwo,
                fstRepInStable, fstPostState, fstRepType, fstAType,
                fstUpdateState,
                StringUtils.getIsStringEqulesNull(fstParameter),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(fstDate),
                StringUtils.getIsStringEqulesNull(fstTime),
                StringUtils.getIsStringEqulesNull(fstRingCode),
                StringUtils.getIsStringEqulesNull(fstRingDesc),
                StringUtils.getIsStringEqulesNull(fstTags),
                StringUtils.getIsStringEqulesNull(fstSourceDesc),
                StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                StringUtils.getIsStringEqulesNull(fstRepeatDate),
                StringUtils.getIsStringEqulesNull(fstRepStartDate),
                StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepDateOne),
                StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                StringUtils.getIsStringEqulesNull(fstRecommendName),
                StringUtils.getIsStringEqulesNull(fstWebURL),
                StringUtils.getIsStringEqulesNull(fstImagePath),
                StringUtils.getIsStringEqulesNull(fstParReamrk),
                StringUtils.getIsStringEqulesNull(fstCreateTime),
                StringUtils.getIsStringEqulesNull(fstUpdateTime),
                StringUtils.getIsStringEqulesNull(fstReamrk1),
                StringUtils.getIsStringEqulesNull(fstReamrk2),
                StringUtils.getIsStringEqulesNull(fstReamrk3),
                StringUtils.getIsStringEqulesNull(fstReamrk4),
                StringUtils.getIsStringEqulesNull(fstReamrk5)};
        // String sql = "insert into CLFindScheduleTable values(" + fstID + ","
        // + fstFID + "," + fstSchID + "," + fstType + "," + fstBeforeTime
        // + "," + fstIsAlarm + "," + fstDisplayTime + "," + fstColorType
        // + "," + fstIsPostpone + "," + fstIsImportant + "," + fstIsEnd
        // + "," + fstSourceType + "," + fstRepeatId + "," + fstOpenState
        // + "," + fstRepeatLink + "," + fstRecommendId + "," + fstIsRead
        // + "," + fstAID + "," + fstIsPuase + "," + fstRepStateOne + ","
        // + fstRepStateTwo + "," + fstRepInStable + "," + fstPostState
        // + "," + fstRepType + "," + fstAType + "," + fstUpdateState
        // + ",'" + fstParameter + "','" + content + "' , '" + fstDate
        // + "' , '" + fstTime + "' , '" + fstRingCode + "', '"
        // + fstRingDesc + "','" + fstTags + "','" + fstSourceDesc + "','"
        // + fstSourceDescSpare + "','" + fstRepeatDate + "','"
        // + fstRepStartDate + "','" + fstRpNextCreatedTime + "','"
        // + fstRepLastCreatedTime + "','" + fstRepInitialCreatedTime
        // + "','" + fstRepDateOne + "','" + fstRepDateTwo + "','"
        // + fstRecommendName + "','" + fstWebURL + "','" + fstImagePath
        // + "','" + fstParReamrk + "','" + fstCreateTime + "','"
        // + fstUpdateTime + "','" + fstReamrk1 + "','" + fstReamrk2
        // + "','" + fstReamrk3 + "','" + fstReamrk4 + "','" + fstReamrk5
        // + "')";
        try {
            sqldb.execSQL(insertStr, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 插入重复数据
     */
    public boolean insertNewFocusData(Integer fstFID, Integer fstType,
                                      Integer fstBeforeTime, Integer fstIsAlarm, Integer fstDisplayTime,
                                      Integer fstColorType, Integer fstIsPostpone,
                                      Integer fstIsImportant, Integer fstIsEnd, Integer fstSourceType,
                                      Integer fstOpenState, Integer fstRepeatLink,
                                      Integer fstRecommendId, Integer fstIsRead, Integer fstAID,
                                      Integer fstIsPuase, Integer fstRepStateOne, Integer fstRepStateTwo,
                                      Integer fstRepInStable, Integer fstPostState, Integer fstRepType,
                                      Integer fstAType, Integer fstUpdateState, String fstParameter,
                                      String fstContent, String fstDate, String fstTime,
                                      String fstRingCode, String fstRingDesc, String fstTags,
                                      String fstSourceDesc, String fstSourceDescSpare,
                                      String fstRepeatDate, String fstRepStartDate,
                                      String fstRpNextCreatedTime, String fstRepLastCreatedTime,
                                      String fstRepInitialCreatedTime, String fstRepDateOne,
                                      String fstRepDateTwo, String fstRecommendName, String fstWebURL,
                                      String fstImagePath, String fstParReamrk, String fstCreateTime,
                                      String fstUpdateTime, String fstReamrk1, String fstReamrk2,
                                      String fstReamrk3, String fstReamrk4, String fstReamrk5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int fstID = getLocalId(1, "CLFindScheduleTable",
                CLFindScheduleTable.fstID);
        int fstSchID = getLocalId(-1, "CLFindScheduleTable",
                CLFindScheduleTable.fstSchID);
        fstRepeatId = getLocalId(-1, "CLFindScheduleTable",
                CLFindScheduleTable.fstRepeatId);
        String content = fstContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String insertStr = "insert into CLFindScheduleTable(fstID,fstFID,fstSchID, fstType,"
                + "fstBeforeTime, fstIsAlarm, fstDisplayTime,fstColorType, fstIsPostpone,"
                + "fstIsImportant,fstIsEnd, fstSourceType,fstRepeatId, fstOpenState, "
                + "fstRepeatLink,fstRecommendId, fstIsRead, fstAID,fstIsPuase, fstRepStateOne,"
                + "fstRepStateTwo,fstRepInStable,fstPostState, fstRepType,fstAType, "
                + "fstUpdateState, fstParameter,fstContent, fstDate, fstTime,fstRingCode,"
                + " fstRingDesc, fstTags,fstSourceDesc, fstSourceDescSpare,fstRepeatDate,"
                + " fstRepStartDate,fstRpNextCreatedTime, fstRepLastCreatedTime,"
                + "fstRepInitialCreatedTime, fstRepDateOne,fstRepDateTwo, fstRecommendName,"
                + " fstWebURL,fstImagePath,fstParReamrk, fstCreateTime,fstUpdateTime, "
                + "fstReamrk1,fstReamrk2,fstReamrk3, fstReamrk4,fstReamrk5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{fstID, fstFID, fstSchID, fstType,
                fstBeforeTime, fstIsAlarm, fstDisplayTime, fstColorType,
                fstIsPostpone, fstIsImportant, fstIsEnd, fstSourceType,
                fstRepeatId, fstOpenState, fstRepeatLink, fstRecommendId,
                fstIsRead, fstAID, fstIsPuase, fstRepStateOne, fstRepStateTwo,
                fstRepInStable, fstPostState, fstRepType, fstAType,
                fstUpdateState,
                StringUtils.getIsStringEqulesNull(fstParameter),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(fstDate),
                StringUtils.getIsStringEqulesNull(fstTime),
                StringUtils.getIsStringEqulesNull(fstRingCode),
                StringUtils.getIsStringEqulesNull(fstRingDesc),
                StringUtils.getIsStringEqulesNull(fstTags),
                StringUtils.getIsStringEqulesNull(fstSourceDesc),
                StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                StringUtils.getIsStringEqulesNull(fstRepeatDate),
                StringUtils.getIsStringEqulesNull(fstRepStartDate),
                StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepDateOne),
                StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                StringUtils.getIsStringEqulesNull(fstRecommendName),
                StringUtils.getIsStringEqulesNull(fstWebURL),
                StringUtils.getIsStringEqulesNull(fstImagePath),
                StringUtils.getIsStringEqulesNull(fstParReamrk),
                StringUtils.getIsStringEqulesNull(fstCreateTime),
                StringUtils.getIsStringEqulesNull(fstUpdateTime),
                StringUtils.getIsStringEqulesNull(fstReamrk1),
                StringUtils.getIsStringEqulesNull(fstReamrk2),
                StringUtils.getIsStringEqulesNull(fstReamrk3),
                StringUtils.getIsStringEqulesNull(fstReamrk4),
                StringUtils.getIsStringEqulesNull(fstReamrk5)};
        // String sql = "insert into CLFindScheduleTable values(" + fstID + ","
        // + fstFID + "," + fstSchID + "," + fstType + "," + fstBeforeTime
        // + "," + fstIsAlarm + "," + fstDisplayTime + "," + fstColorType
        // + "," + fstIsPostpone + "," + fstIsImportant + "," + fstIsEnd
        // + "," + fstSourceType + "," + fstRepeatId + "," + fstOpenState
        // + "," + fstRepeatLink + "," + fstRecommendId + "," + fstIsRead
        // + "," + fstAID + "," + fstIsPuase + "," + fstRepStateOne + ","
        // + fstRepStateTwo + "," + fstRepInStable + "," + fstPostState
        // + "," + fstRepType + "," + fstAType + "," + fstUpdateState
        // + ",'" + fstParameter + "','" + content + "' , '" + fstDate
        // + "' , '" + fstTime + "' , '" + fstRingCode + "', '"
        // + fstRingDesc + "','" + fstTags + "','" + fstSourceDesc + "','"
        // + fstSourceDescSpare + "','" + fstRepeatDate + "','"
        // + fstRepStartDate + "','" + fstRpNextCreatedTime + "','"
        // + fstRepLastCreatedTime + "','" + fstRepInitialCreatedTime
        // + "','" + fstRepDateOne + "','" + fstRepDateTwo + "','"
        // + fstRecommendName + "','" + fstWebURL + "','" + fstImagePath
        // + "','" + fstParReamrk + "','" + fstCreateTime + "','"
        // + fstUpdateTime + "','" + fstReamrk1 + "','" + fstReamrk2
        // + "','" + fstReamrk3 + "','" + fstReamrk4 + "','" + fstReamrk5
        // + "')";
        try {
            sqldb.execSQL(insertStr, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 从网上下载数据插入到新版分享表中
     *
     * @return
     */
    public boolean insertNewFocusFromIntenetData(Integer fstFID,
                                                 Integer fstSchID, Integer fstType, Integer fstBeforeTime,
                                                 Integer fstIsAlarm, Integer fstDisplayTime, Integer fstColorType,
                                                 Integer fstIsPostpone, Integer fstIsImportant, Integer fstIsEnd,
                                                 Integer fstSourceType, Integer fstRepeatId, Integer fstOpenState,
                                                 Integer fstRepeatLink, Integer fstRecommendId, Integer fstIsRead,
                                                 Integer fstAID, Integer fstIsPuase, Integer fstRepStateOne,
                                                 Integer fstRepStateTwo, Integer fstRepInStable,
                                                 Integer fstPostState, Integer fstRepType, Integer fstAType,
                                                 Integer fstUpdateState, String fstParameter, String fstContent,
                                                 String fstDate, String fstTime, String fstRingCode,
                                                 String fstRingDesc, String fstTags, String fstSourceDesc,
                                                 String fstSourceDescSpare, String fstRepeatDate,
                                                 String fstRepStartDate, String fstRpNextCreatedTime,
                                                 String fstRepLastCreatedTime, String fstRepInitialCreatedTime,
                                                 String fstRepDateOne, String fstRepDateTwo,
                                                 String fstRecommendName, String fstWebURL, String fstImagePath,
                                                 String fstParReamrk, String fstCreateTime, String fstUpdateTime,
                                                 String fstReamrk1, String fstReamrk2, String fstReamrk3,
                                                 String fstReamrk4, String fstReamrk5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int fstID = getLocalId(1, "CLFindScheduleTable",
                CLFindScheduleTable.fstID);
        String content = fstContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String insertStr = "insert into CLFindScheduleTable(fstID,fstFID,fstSchID, fstType,"
                + "fstBeforeTime, fstIsAlarm, fstDisplayTime,fstColorType, fstIsPostpone,"
                + "fstIsImportant,fstIsEnd, fstSourceType,fstRepeatId, fstOpenState, "
                + "fstRepeatLink,fstRecommendId, fstIsRead, fstAID,fstIsPuase, fstRepStateOne,"
                + "fstRepStateTwo,fstRepInStable,fstPostState, fstRepType,fstAType, "
                + "fstUpdateState, fstParameter,fstContent, fstDate, fstTime,fstRingCode,"
                + " fstRingDesc, fstTags,fstSourceDesc, fstSourceDescSpare,fstRepeatDate,"
                + " fstRepStartDate,fstRpNextCreatedTime, fstRepLastCreatedTime,"
                + "fstRepInitialCreatedTime, fstRepDateOne,fstRepDateTwo, fstRecommendName,"
                + " fstWebURL,fstImagePath,fstParReamrk, fstCreateTime,fstUpdateTime, "
                + "fstReamrk1,fstReamrk2,fstReamrk3, fstReamrk4,fstReamrk5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{fstID, fstFID, fstSchID, fstType,
                fstBeforeTime, fstIsAlarm, fstDisplayTime, fstColorType,
                fstIsPostpone, fstIsImportant, fstIsEnd, fstSourceType,
                fstRepeatId, fstOpenState, fstRepeatLink, fstRecommendId,
                fstIsRead, fstAID, fstIsPuase, fstRepStateOne, fstRepStateTwo,
                fstRepInStable, fstPostState, fstRepType, fstAType,
                fstUpdateState,
                StringUtils.getIsStringEqulesNull(fstParameter),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(fstDate),
                StringUtils.getIsStringEqulesNull(fstTime),
                StringUtils.getIsStringEqulesNull(fstRingCode),
                StringUtils.getIsStringEqulesNull(fstRingDesc),
                StringUtils.getIsStringEqulesNull(fstTags),
                StringUtils.getIsStringEqulesNull(fstSourceDesc),
                StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                StringUtils.getIsStringEqulesNull(fstRepeatDate),
                StringUtils.getIsStringEqulesNull(fstRepStartDate),
                StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepDateOne),
                StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                StringUtils.getIsStringEqulesNull(fstRecommendName),
                StringUtils.getIsStringEqulesNull(fstWebURL),
                StringUtils.getIsStringEqulesNull(fstImagePath),
                StringUtils.getIsStringEqulesNull(fstParReamrk),
                StringUtils.getIsStringEqulesNull(fstCreateTime),
                StringUtils.getIsStringEqulesNull(fstUpdateTime),
                StringUtils.getIsStringEqulesNull(fstReamrk1),
                StringUtils.getIsStringEqulesNull(fstReamrk2),
                StringUtils.getIsStringEqulesNull(fstReamrk3),
                StringUtils.getIsStringEqulesNull(fstReamrk4),
                StringUtils.getIsStringEqulesNull(fstReamrk5)};
        // String sql = "insert into CLFindScheduleTable values(" + fstID + ","
        // + fstFID + "," + fstSchID + "," + fstType + "," + fstBeforeTime
        // + "," + fstIsAlarm + "," + fstDisplayTime + "," + fstColorType
        // + "," + fstIsPostpone + "," + fstIsImportant + "," + fstIsEnd
        // + "," + fstSourceType + "," + fstRepeatId + "," + fstOpenState
        // + "," + fstRepeatLink + "," + fstRecommendId + "," + fstIsRead
        // + "," + fstAID + "," + fstIsPuase + "," + fstRepStateOne + ","
        // + fstRepStateTwo + "," + fstRepInStable + "," + fstPostState
        // + "," + fstRepType + "," + fstAType + "," + fstUpdateState
        // + ",'" + fstParameter + "','" + content + "' , '" + fstDate
        // + "' , '" + fstTime + "' , '" + fstRingCode + "', '"
        // + fstRingDesc + "','" + fstTags + "','" + fstSourceDesc + "','"
        // + fstSourceDescSpare + "','" + fstRepeatDate + "','"
        // + fstRepStartDate + "','" + fstRpNextCreatedTime + "','"
        // + fstRepLastCreatedTime + "','" + fstRepInitialCreatedTime
        // + "','" + fstRepDateOne + "','" + fstRepDateTwo + "','"
        // + fstRecommendName + "','" + fstWebURL + "','" + fstImagePath
        // + "','" + fstParReamrk + "','" + fstCreateTime + "','"
        // + fstUpdateTime + "','" + fstReamrk1 + "','" + fstReamrk2
        // + "','" + fstReamrk3 + "','" + fstReamrk4 + "','" + fstReamrk5
        // + "')";
        try {
            sqldb.execSQL(insertStr, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 从网上下载重复插入
     *
     * @return
     */
    public void insertNewFocusFromIntenetRepeatData(Integer fstFID,
                                                    Integer fstType, Integer fstBeforeTime, Integer fstIsAlarm,
                                                    Integer fstDisplayTime, Integer fstColorType,
                                                    Integer fstIsPostpone, Integer fstIsImportant, Integer fstIsEnd,
                                                    Integer fstSourceType, Integer fstRepeatId, Integer fstOpenState,
                                                    Integer fstRepeatLink, Integer fstRecommendId, Integer fstIsRead,
                                                    Integer fstAID, Integer fstIsPuase, Integer fstRepStateOne,
                                                    Integer fstRepStateTwo, Integer fstRepInStable,
                                                    Integer fstPostState, Integer fstRepType, Integer fstAType,
                                                    Integer fstUpdateState, String fstParameter, String fstContent,
                                                    String fstDate, String fstTime, String fstRingCode,
                                                    String fstRingDesc, String fstTags, String fstSourceDesc,
                                                    String fstSourceDescSpare, String fstRepeatDate,
                                                    String fstRepStartDate, String fstRpNextCreatedTime,
                                                    String fstRepLastCreatedTime, String fstRepInitialCreatedTime,
                                                    String fstRepDateOne, String fstRepDateTwo,
                                                    String fstRecommendName, String fstWebURL, String fstImagePath,
                                                    String fstParReamrk, String fstCreateTime, String fstUpdateTime,
                                                    String fstReamrk1, String fstReamrk2, String fstReamrk3,
                                                    String fstReamrk4, String fstReamrk5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int fstID = getLocalId(1, "CLFindScheduleTable",
                CLFindScheduleTable.fstID);
        int fstSchID = getLocalId(-1, "CLFindScheduleTable",
                CLFindScheduleTable.fstSchID);
        String content = fstContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String insertStr = "insert into CLFindScheduleTable(fstID,fstFID,fstSchID, fstType,"
                + "fstBeforeTime, fstIsAlarm, fstDisplayTime,fstColorType, fstIsPostpone,"
                + "fstIsImportant,fstIsEnd, fstSourceType,fstRepeatId, fstOpenState, "
                + "fstRepeatLink,fstRecommendId, fstIsRead, fstAID,fstIsPuase, fstRepStateOne,"
                + "fstRepStateTwo,fstRepInStable,fstPostState, fstRepType,fstAType, "
                + "fstUpdateState, fstParameter,fstContent, fstDate, fstTime,fstRingCode,"
                + " fstRingDesc, fstTags,fstSourceDesc, fstSourceDescSpare,fstRepeatDate,"
                + " fstRepStartDate,fstRpNextCreatedTime, fstRepLastCreatedTime,"
                + "fstRepInitialCreatedTime, fstRepDateOne,fstRepDateTwo, fstRecommendName,"
                + " fstWebURL,fstImagePath,fstParReamrk, fstCreateTime,fstUpdateTime, "
                + "fstReamrk1,fstReamrk2,fstReamrk3, fstReamrk4,fstReamrk5) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{fstID, fstFID, fstSchID, fstType,
                fstBeforeTime, fstIsAlarm, fstDisplayTime, fstColorType,
                fstIsPostpone, fstIsImportant, fstIsEnd, fstSourceType,
                fstRepeatId, fstOpenState, fstRepeatLink, fstRecommendId,
                fstIsRead, fstAID, fstIsPuase, fstRepStateOne, fstRepStateTwo,
                fstRepInStable, fstPostState, fstRepType, fstAType,
                fstUpdateState,
                StringUtils.getIsStringEqulesNull(fstParameter),
                StringUtils.getIsStringEqulesNull(content),
                StringUtils.getIsStringEqulesNull(fstDate),
                StringUtils.getIsStringEqulesNull(fstTime),
                StringUtils.getIsStringEqulesNull(fstRingCode),
                StringUtils.getIsStringEqulesNull(fstRingDesc),
                StringUtils.getIsStringEqulesNull(fstTags),
                StringUtils.getIsStringEqulesNull(fstSourceDesc),
                StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                StringUtils.getIsStringEqulesNull(fstRepeatDate),
                StringUtils.getIsStringEqulesNull(fstRepStartDate),
                StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                StringUtils.getIsStringEqulesNull(fstRepDateOne),
                StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                StringUtils.getIsStringEqulesNull(fstRecommendName),
                StringUtils.getIsStringEqulesNull(fstWebURL),
                StringUtils.getIsStringEqulesNull(fstImagePath),
                StringUtils.getIsStringEqulesNull(fstParReamrk),
                StringUtils.getIsStringEqulesNull(fstCreateTime),
                StringUtils.getIsStringEqulesNull(fstUpdateTime),
                StringUtils.getIsStringEqulesNull(fstReamrk1),
                StringUtils.getIsStringEqulesNull(fstReamrk2),
                StringUtils.getIsStringEqulesNull(fstReamrk3),
                StringUtils.getIsStringEqulesNull(fstReamrk4),
                StringUtils.getIsStringEqulesNull(fstReamrk5)};
        // String sql = "insert into CLFindScheduleTable values(" + fstID + ","
        // + fstFID + "," + fstSchID + "," + fstType + "," + fstBeforeTime
        // + "," + fstIsAlarm + "," + fstDisplayTime + "," + fstColorType
        // + "," + fstIsPostpone + "," + fstIsImportant + "," + fstIsEnd
        // + "," + fstSourceType + "," + fstRepeatId + "," + fstOpenState
        // + "," + fstRepeatLink + "," + fstRecommendId + "," + fstIsRead
        // + "," + fstAID + "," + fstIsPuase + "," + fstRepStateOne + ","
        // + fstRepStateTwo + "," + fstRepInStable + "," + fstPostState
        // + "," + fstRepType + "," + fstAType + "," + fstUpdateState
        // + ",'" + fstParameter + "','" + content + "' , '" + fstDate
        // + "' , '" + fstTime + "' , '" + fstRingCode + "', '"
        // + fstRingDesc + "','" + fstTags + "','" + fstSourceDesc + "','"
        // + fstSourceDescSpare + "','" + fstRepeatDate + "','"
        // + fstRepStartDate + "','" + fstRpNextCreatedTime + "','"
        // + fstRepLastCreatedTime + "','" + fstRepInitialCreatedTime
        // + "','" + fstRepDateOne + "','" + fstRepDateTwo + "','"
        // + fstRecommendName + "','" + fstWebURL + "','" + fstImagePath
        // + "','" + fstParReamrk + "','" + fstCreateTime + "','"
        // + fstUpdateTime + "','" + fstReamrk1 + "','" + fstReamrk2
        // + "','" + fstReamrk3 + "','" + fstReamrk4 + "','" + fstReamrk5
        // + "')";
        try {
            sqldb.execSQL(insertStr, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 与网上数据进行同步，修改本地数据
     */
    public boolean updateNewFocusFromIntenetData(Integer fstFID,
                                                 Integer fstSchID, Integer fstType, Integer fstBeforeTime,
                                                 Integer fstIsAlarm, Integer fstDisplayTime, Integer fstColorType,
                                                 Integer fstIsPostpone, Integer fstIsImportant, Integer fstIsEnd,
                                                 Integer fstSourceType, Integer fstRepeatId, Integer fstOpenState,
                                                 Integer fstRepeatLink, Integer fstRecommendId, Integer fstIsRead,
                                                 Integer fstAID, Integer fstIsPuase, Integer fstRepStateOne,
                                                 Integer fstRepStateTwo, Integer fstRepInStable,
                                                 Integer fstPostState, Integer fstRepType, Integer fstAType,
                                                 Integer fstUpdateState, String fstParameter, String fstContent,
                                                 String fstDate, String fstTime, String fstRingCode,
                                                 String fstRingDesc, String fstTags, String fstSourceDesc,
                                                 String fstSourceDescSpare, String fstRepeatDate,
                                                 String fstRepStartDate, String fstRpNextCreatedTime,
                                                 String fstRepLastCreatedTime, String fstRepInitialCreatedTime,
                                                 String fstRepDateOne, String fstRepDateTwo,
                                                 String fstRecommendName, String fstWebURL, String fstImagePath,
                                                 String fstParReamrk, String fstCreateTime, String fstUpdateTime,
                                                 String fstReamrk1, String fstReamrk2, String fstReamrk3,
                                                 String fstReamrk4, String fstReamrk5) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String content = fstContent
                .replaceAll(
                        "[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]",
                        "");
        String sql = "";
        Object[] mValue = null;
        if (fstType == 0) {
            sql = "update CLFindScheduleTable set fstFID=?,fstSchID=?, fstType=?,"
                    + "fstBeforeTime=?, fstIsAlarm=?, fstDisplayTime=?,fstColorType=?, fstIsPostpone=?,"
                    + "fstIsImportant=?,fstIsEnd=?, fstSourceType=?,fstRepeatId=?, fstOpenState=?, "
                    + "fstRepeatLink=?,fstRecommendId=?, fstIsRead=?, fstAID=?,fstIsPuase=?, fstRepStateOne=?,"
                    + "fstRepStateTwo=?,fstRepInStable=?,fstPostState=?, fstRepType=?,fstAType=?, "
                    + "fstUpdateState=?, fstParameter=?,fstContent=?, fstDate=?, fstTime=?,fstRingCode=?,"
                    + " fstRingDesc=?, fstTags=?,fstSourceDesc=?, fstSourceDescSpare=?,fstRepeatDate=?,"
                    + " fstRepStartDate=?,fstRpNextCreatedTime=?, fstRepLastCreatedTime=?,"
                    + "fstRepInitialCreatedTime=?, fstRepDateOne=?,fstRepDateTwo=?, fstRecommendName=?,"
                    + " fstWebURL=?,fstImagePath=?,fstParReamrk=?, fstCreateTime=?,fstUpdateTime=?, "
                    + "fstReamrk1=?,fstReamrk2=?,fstReamrk3=?, fstReamrk4=?,fstReamrk5=? "
                    + " where "
                    + CLFindScheduleTable.fstSchID
                    + " = "
                    + fstSchID
                    + " and "
                    + CLFindScheduleTable.fstUpdateState
                    + " != "
                    + 3
                    + " and "
                    + CLFindScheduleTable.fstRepeatId
                    + " = " + 0;
            mValue = new Object[]{
                    fstFID,
                    fstSchID,
                    fstType,
                    fstBeforeTime,
                    fstIsAlarm,
                    fstDisplayTime,
                    fstColorType,
                    fstIsPostpone,
                    fstIsImportant,
                    fstIsEnd,
                    fstSourceType,
                    fstRepeatId,
                    fstOpenState,
                    fstRepeatLink,
                    fstRecommendId,
                    fstIsRead,
                    fstAID,
                    fstIsPuase,
                    fstRepStateOne,
                    fstRepStateTwo,
                    fstRepInStable,
                    fstPostState,
                    fstRepType,
                    fstAType,
                    fstUpdateState,
                    StringUtils.getIsStringEqulesNull(fstParameter),
                    StringUtils.getIsStringEqulesNull(content),
                    StringUtils.getIsStringEqulesNull(fstDate),
                    StringUtils.getIsStringEqulesNull(fstTime),
                    StringUtils.getIsStringEqulesNull(fstRingCode),
                    StringUtils.getIsStringEqulesNull(fstRingDesc),
                    StringUtils.getIsStringEqulesNull(fstTags),
                    StringUtils.getIsStringEqulesNull(fstSourceDesc),
                    StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                    StringUtils.getIsStringEqulesNull(fstRepeatDate),
                    StringUtils.getIsStringEqulesNull(fstRepStartDate),
                    StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepDateOne),
                    StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                    StringUtils.getIsStringEqulesNull(fstRecommendName),
                    StringUtils.getIsStringEqulesNull(fstWebURL),
                    StringUtils.getIsStringEqulesNull(fstImagePath),
                    StringUtils.getIsStringEqulesNull(fstParReamrk),
                    StringUtils.getIsStringEqulesNull(fstCreateTime),
                    StringUtils.getIsStringEqulesNull(fstUpdateTime),
                    StringUtils.getIsStringEqulesNull(fstReamrk1),
                    StringUtils.getIsStringEqulesNull(fstReamrk2),
                    StringUtils.getIsStringEqulesNull(fstReamrk3),
                    StringUtils.getIsStringEqulesNull(fstReamrk4),
                    StringUtils.getIsStringEqulesNull(fstReamrk5)};
            // sql = "update " + CLFindScheduleTable.CLFindScheduleTable +
            // " set "
            // + CLFindScheduleTable.fstFID + " = " + fstFID + ", "
            // + CLFindScheduleTable.fstSchID + " = " + fstSchID + ", "
            // + CLFindScheduleTable.fstType + " = " + fstType + ", "
            // + CLFindScheduleTable.fstBeforeTime + " = " + fstBeforeTime
            // + ", " + CLFindScheduleTable.fstIsAlarm + " = "
            // + fstIsAlarm + ", " + CLFindScheduleTable.fstDisplayTime
            // + " = " + fstDisplayTime + ", "
            // + CLFindScheduleTable.fstColorType + " = " + fstColorType
            // + ", " + CLFindScheduleTable.fstIsPostpone + " = "
            // + fstIsPostpone + ", " + CLFindScheduleTable.fstIsImportant
            // + " = '" + fstIsImportant + "', "
            // + CLFindScheduleTable.fstIsEnd + " = " + fstIsEnd + ", "
            // + CLFindScheduleTable.fstSourceType + " = " + fstSourceType
            // + ", " + CLFindScheduleTable.fstRepeatId + " = "
            // + fstRepeatId + ", " + CLFindScheduleTable.fstOpenState
            // + " = " + fstOpenState + ", "
            // + CLFindScheduleTable.fstRepeatLink + " = " + fstRepeatLink
            // + ", " + CLFindScheduleTable.fstRecommendId + " = "
            // + fstRecommendId + ", " + CLFindScheduleTable.fstIsRead
            // + " = " + fstIsRead + ", " + CLFindScheduleTable.fstAID
            // + " = " + fstAID + ", " + CLFindScheduleTable.fstIsPuase
            // + " = " + fstIsPuase + ", "
            // + CLFindScheduleTable.fstRepStateOne + " = "
            // + fstRepStateOne + ", "
            // + CLFindScheduleTable.fstRepStateTwo + " = "
            // + fstRepStateTwo + ", "
            // + CLFindScheduleTable.fstRepInStable + " = "
            // + fstRepInStable + ", " + CLFindScheduleTable.fstPostState
            // + " = " + fstPostState + ", "
            // + CLFindScheduleTable.fstRepType + " = " + fstRepType
            // + ", " + CLFindScheduleTable.fstAType + " = " + fstAType
            // + ", " + CLFindScheduleTable.fstUpdateState + " = "
            // + fstUpdateState + ", " + CLFindScheduleTable.fstParameter
            // + " = '" + fstParameter + "', "
            // + CLFindScheduleTable.fstContent + " = '" + content + "', "
            // + CLFindScheduleTable.fstDate + " = '" + fstDate + "', "
            // + CLFindScheduleTable.fstTime + " = '" + fstTime + "', "
            // + CLFindScheduleTable.fstRingCode + " = '" + fstRingCode
            // + "', " + CLFindScheduleTable.fstRingDesc + " = '"
            // + fstRingDesc + "', " + CLFindScheduleTable.fstTags
            // + " = '" + fstTags + "', "
            // + CLFindScheduleTable.fstSourceDesc + " ='"
            // + fstSourceDesc + "', "
            // + CLFindScheduleTable.fstSourceDescSpare + " = '"
            // + fstSourceDescSpare + "', "
            // + CLFindScheduleTable.fstRepeatDate + " ='"
            // + fstRepeatDate + "' , "
            // + CLFindScheduleTable.fstRepStartDate + " = '"
            // + fstRepStartDate + "' , "
            // + CLFindScheduleTable.fstRpNextCreatedTime + " ='"
            // + fstRpNextCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepLastCreatedTime + " = '"
            // + fstRepLastCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepInitialCreatedTime + " ='"
            // + fstRepInitialCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepDateOne + " = '"
            // + fstRepDateOne + "' , "
            // + CLFindScheduleTable.fstRepDateTwo + " ='"
            // + fstRepDateTwo + "' , "
            // + CLFindScheduleTable.fstRecommendName + " = '"
            // + fstRecommendName + "' , " + CLFindScheduleTable.fstWebURL
            // + " = '" + fstWebURL + "' , "
            // + CLFindScheduleTable.fstImagePath + " = '" + fstImagePath
            // + "' , " + CLFindScheduleTable.fstParReamrk + " = '"
            // + fstParReamrk + "' , " + CLFindScheduleTable.fstCreateTime
            // + " = '" + fstCreateTime + "' , "
            // + CLFindScheduleTable.fstUpdateTime + " = '"
            // + fstUpdateTime + "' , " + CLFindScheduleTable.fstReamrk1
            // + " = '" + fstReamrk1 + "' , "
            // + CLFindScheduleTable.fstReamrk2 + " = '" + fstReamrk2
            // + "' , " + CLFindScheduleTable.fstReamrk3 + " = '"
            // + fstReamrk3 + "' , " + CLFindScheduleTable.fstReamrk4
            // + " = '" + fstReamrk4 + "' , "
            // + CLFindScheduleTable.fstReamrk5 + " = '" + fstReamrk5
            // + "' where " + CLFindScheduleTable.fstSchID + " = "
            // + fstSchID + " and " + CLFindScheduleTable.fstUpdateState
            // + " != " + 3 + " and " + CLFindScheduleTable.fstRepeatId
            // + " = " +0;
        } else if (fstType == 2) {//
            int schID = getLocalId(-1, "CLFindScheduleTable",
                    CLFindScheduleTable.fstSchID);
            sql = "update CLFindScheduleTable set fstFID=?,fstSchID=?, fstType=?,"
                    + "fstBeforeTime=?, fstIsAlarm=?, fstDisplayTime=?,fstColorType=?, fstIsPostpone=?,"
                    + "fstIsImportant=?,fstIsEnd=?, fstSourceType=?,fstRepeatId=?, fstOpenState=?, "
                    + "fstRepeatLink=?,fstRecommendId=?, fstIsRead=?, fstAID=?,fstIsPuase=?, fstRepStateOne=?,"
                    + "fstRepStateTwo=?,fstRepInStable=?,fstPostState=?, fstRepType=?,fstAType=?, "
                    + "fstUpdateState=?, fstParameter=?,fstContent=?, fstDate=?, fstTime=?,fstRingCode=?,"
                    + " fstRingDesc=?, fstTags=?,fstSourceDesc=?, fstSourceDescSpare=?,fstRepeatDate=?,"
                    + " fstRepStartDate=?,fstRpNextCreatedTime=?, fstRepLastCreatedTime=?,"
                    + "fstRepInitialCreatedTime=?, fstRepDateOne=?,fstRepDateTwo=?, fstRecommendName=?,"
                    + " fstWebURL=?,fstImagePath=?,fstParReamrk=?, fstCreateTime=?,fstUpdateTime=?, "
                    + "fstReamrk1=?,fstReamrk2=?,fstReamrk3=?, fstReamrk4=?,fstReamrk5=? "
                    + " where "
                    + CLFindScheduleTable.fstRepeatId
                    + " = "
                    + fstRepeatId
                    + " and "
                    + CLFindScheduleTable.fstUpdateState + " != " + 3;
            mValue = new Object[]{
                    fstFID,
                    schID,
                    1,
                    fstBeforeTime,
                    fstIsAlarm,
                    fstDisplayTime,
                    fstColorType,
                    fstIsPostpone,
                    fstIsImportant,
                    fstIsEnd,
                    fstSourceType,
                    fstRepeatId,
                    fstOpenState,
                    fstRepeatLink,
                    fstRecommendId,
                    fstIsRead,
                    fstAID,
                    fstIsPuase,
                    fstRepStateOne,
                    fstRepStateTwo,
                    fstRepInStable,
                    fstPostState,
                    fstRepType,
                    fstAType,
                    fstUpdateState,
                    StringUtils.getIsStringEqulesNull(fstParameter),
                    StringUtils.getIsStringEqulesNull(content),
                    StringUtils.getIsStringEqulesNull(fstDate),
                    StringUtils.getIsStringEqulesNull(fstTime),
                    StringUtils.getIsStringEqulesNull(fstRingCode),
                    StringUtils.getIsStringEqulesNull(fstRingDesc),
                    StringUtils.getIsStringEqulesNull(fstTags),
                    StringUtils.getIsStringEqulesNull(fstSourceDesc),
                    StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                    StringUtils.getIsStringEqulesNull(fstRepeatDate),
                    StringUtils.getIsStringEqulesNull(fstRepStartDate),
                    StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepDateOne),
                    StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                    StringUtils.getIsStringEqulesNull(fstRecommendName),
                    StringUtils.getIsStringEqulesNull(fstWebURL),
                    StringUtils.getIsStringEqulesNull(fstImagePath),
                    StringUtils.getIsStringEqulesNull(fstParReamrk),
                    StringUtils.getIsStringEqulesNull(fstCreateTime),
                    StringUtils.getIsStringEqulesNull(fstUpdateTime),
                    StringUtils.getIsStringEqulesNull(fstReamrk1),
                    StringUtils.getIsStringEqulesNull(fstReamrk2),
                    StringUtils.getIsStringEqulesNull(fstReamrk3),
                    StringUtils.getIsStringEqulesNull(fstReamrk4),
                    StringUtils.getIsStringEqulesNull(fstReamrk5)};
            // sql = "update " + CLFindScheduleTable.CLFindScheduleTable +
            // " set "
            // + CLFindScheduleTable.fstFID + " = " + fstFID + ", "
            // + CLFindScheduleTable.fstSchID + " = " + schID + ", "
            // + CLFindScheduleTable.fstType + " = " + 1 + ", "
            // + CLFindScheduleTable.fstBeforeTime + " = " + fstBeforeTime
            // + ", " + CLFindScheduleTable.fstIsAlarm + " = "
            // + fstIsAlarm + ", " + CLFindScheduleTable.fstDisplayTime
            // + " = " + fstDisplayTime + ", "
            // + CLFindScheduleTable.fstColorType + " = " + fstColorType
            // + ", " + CLFindScheduleTable.fstIsPostpone + " = "
            // + fstIsPostpone + ", " + CLFindScheduleTable.fstIsImportant
            // + " = '" + fstIsImportant + "', "
            // + CLFindScheduleTable.fstIsEnd + " = " + fstIsEnd + ", "
            // + CLFindScheduleTable.fstSourceType + " = " + fstSourceType
            // + ", " + CLFindScheduleTable.fstRepeatId + " = "
            // + fstRepeatId + ", " + CLFindScheduleTable.fstOpenState
            // + " = " + fstOpenState + ", "
            // + CLFindScheduleTable.fstRepeatLink + " = " + fstRepeatLink
            // + ", " + CLFindScheduleTable.fstRecommendId + " = "
            // + fstRecommendId + ", " + CLFindScheduleTable.fstIsRead
            // + " = " + fstIsRead + ", " + CLFindScheduleTable.fstAID
            // + " = " + fstAID + ", " + CLFindScheduleTable.fstIsPuase
            // + " = " + fstIsPuase + ", "
            // + CLFindScheduleTable.fstRepStateOne + " = "
            // + fstRepStateOne + ", "
            // + CLFindScheduleTable.fstRepStateTwo + " = "
            // + fstRepStateTwo + ", "
            // + CLFindScheduleTable.fstRepInStable + " = "
            // + fstRepInStable + ", " + CLFindScheduleTable.fstPostState
            // + " = " + fstPostState + ", "
            // + CLFindScheduleTable.fstRepType + " = " + fstRepType
            // + ", " + CLFindScheduleTable.fstAType + " = " + fstAType
            // + ", " + CLFindScheduleTable.fstUpdateState + " = "
            // + fstUpdateState + ", " + CLFindScheduleTable.fstParameter
            // + " = '" + fstParameter + "', "
            // + CLFindScheduleTable.fstContent + " = '" + content + "', "
            // + CLFindScheduleTable.fstDate + " = '" + fstDate + "', "
            // + CLFindScheduleTable.fstTime + " = '" + fstTime + "', "
            // + CLFindScheduleTable.fstRingCode + " = '" + fstRingCode
            // + "', " + CLFindScheduleTable.fstRingDesc + " = '"
            // + fstRingDesc + "', " + CLFindScheduleTable.fstTags
            // + " = '" + fstTags + "', "
            // + CLFindScheduleTable.fstSourceDesc + " = '"
            // + fstSourceDesc + "', "
            // + CLFindScheduleTable.fstSourceDescSpare + " = '"
            // + fstSourceDescSpare + "', "
            // + CLFindScheduleTable.fstRepeatDate + " = '"
            // + fstRepeatDate + "' , "
            // + CLFindScheduleTable.fstRepStartDate + " = '"
            // + fstRepStartDate + "' , "
            // + CLFindScheduleTable.fstRpNextCreatedTime + " = '"
            // + fstRpNextCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepLastCreatedTime + " = '"
            // + fstRepLastCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepInitialCreatedTime + " = '"
            // + fstRepInitialCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepDateOne + " = '"
            // + fstRepDateOne + "' , "
            // + CLFindScheduleTable.fstRepDateTwo + " = '"
            // + fstRepDateTwo + "' , "
            // + CLFindScheduleTable.fstRecommendName + " = '"
            // + fstRecommendName + "' , " + CLFindScheduleTable.fstWebURL
            // + " = '" + fstWebURL + "' , "
            // + CLFindScheduleTable.fstImagePath + " = '" + fstImagePath
            // + "' , " + CLFindScheduleTable.fstParReamrk + " = '"
            // + fstParReamrk + "' , " + CLFindScheduleTable.fstCreateTime
            // + " = '" + fstCreateTime + "' , "
            // + CLFindScheduleTable.fstUpdateTime + " = '"
            // + fstUpdateTime + "' , " + CLFindScheduleTable.fstReamrk1
            // + " = '" + fstReamrk1 + "' , "
            // + CLFindScheduleTable.fstReamrk2 + " = '" + fstReamrk2
            // + "' , " + CLFindScheduleTable.fstReamrk3 + " = '"
            // + fstReamrk3 + "' , " + CLFindScheduleTable.fstReamrk4
            // + " = '" + fstReamrk4 + "' , "
            // + CLFindScheduleTable.fstReamrk5 + " = '" + fstReamrk5
            // + "' where " + CLFindScheduleTable.fstRepeatId + " = "
            // + fstRepeatId + " and "
            // + CLFindScheduleTable.fstUpdateState + " != " +3;
        } else {
            sql = "update CLFindScheduleTable set fstFID=?,fstSchID=?, fstType=?,"
                    + "fstBeforeTime=?, fstIsAlarm=?, fstDisplayTime=?,fstColorType=?, fstIsPostpone=?,"
                    + "fstIsImportant=?,fstIsEnd=?, fstSourceType=?,fstRepeatId=?, fstOpenState=?, "
                    + "fstRepeatLink=?,fstRecommendId=?, fstIsRead=?, fstAID=?,fstIsPuase=?, fstRepStateOne=?,"
                    + "fstRepStateTwo=?,fstRepInStable=?,fstPostState=?, fstRepType=?,fstAType=?, "
                    + "fstUpdateState=?, fstParameter=?,fstContent=?, fstDate=?, fstTime=?,fstRingCode=?,"
                    + " fstRingDesc=?, fstTags=?,fstSourceDesc=?, fstSourceDescSpare=?,fstRepeatDate=?,"
                    + " fstRepStartDate=?,fstRpNextCreatedTime=?, fstRepLastCreatedTime=?,"
                    + "fstRepInitialCreatedTime=?, fstRepDateOne=?,fstRepDateTwo=?, fstRecommendName=?,"
                    + " fstWebURL=?,fstImagePath=?,fstParReamrk=?, fstCreateTime=?,fstUpdateTime=?, "
                    + "fstReamrk1=?,fstReamrk2=?,fstReamrk3=?, fstReamrk4=?,fstReamrk5=? "
                    + " where "
                    + CLFindScheduleTable.fstRepeatId
                    + " = "
                    + fstRepeatId
                    + " and "
                    + CLFindScheduleTable.fstUpdateState + " != " + 3;
            mValue = new Object[]{
                    fstFID,
                    fstSchID,
                    fstType,
                    fstBeforeTime,
                    fstIsAlarm,
                    fstDisplayTime,
                    fstColorType,
                    fstIsPostpone,
                    fstIsImportant,
                    fstIsEnd,
                    fstSourceType,
                    fstRepeatId,
                    fstOpenState,
                    fstRepeatLink,
                    fstRecommendId,
                    fstIsRead,
                    fstAID,
                    fstIsPuase,
                    fstRepStateOne,
                    fstRepStateTwo,
                    fstRepInStable,
                    fstPostState,
                    fstRepType,
                    fstAType,
                    fstUpdateState,
                    StringUtils.getIsStringEqulesNull(fstParameter),
                    StringUtils.getIsStringEqulesNull(content),
                    StringUtils.getIsStringEqulesNull(fstDate),
                    StringUtils.getIsStringEqulesNull(fstTime),
                    StringUtils.getIsStringEqulesNull(fstRingCode),
                    StringUtils.getIsStringEqulesNull(fstRingDesc),
                    StringUtils.getIsStringEqulesNull(fstTags),
                    StringUtils.getIsStringEqulesNull(fstSourceDesc),
                    StringUtils.getIsStringEqulesNull(fstSourceDescSpare),
                    StringUtils.getIsStringEqulesNull(fstRepeatDate),
                    StringUtils.getIsStringEqulesNull(fstRepStartDate),
                    StringUtils.getIsStringEqulesNull(fstRpNextCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepLastCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepInitialCreatedTime),
                    StringUtils.getIsStringEqulesNull(fstRepDateOne),
                    StringUtils.getIsStringEqulesNull(fstRepDateTwo),
                    StringUtils.getIsStringEqulesNull(fstRecommendName),
                    StringUtils.getIsStringEqulesNull(fstWebURL),
                    StringUtils.getIsStringEqulesNull(fstImagePath),
                    StringUtils.getIsStringEqulesNull(fstParReamrk),
                    StringUtils.getIsStringEqulesNull(fstCreateTime),
                    StringUtils.getIsStringEqulesNull(fstUpdateTime),
                    StringUtils.getIsStringEqulesNull(fstReamrk1),
                    StringUtils.getIsStringEqulesNull(fstReamrk2),
                    StringUtils.getIsStringEqulesNull(fstReamrk3),
                    StringUtils.getIsStringEqulesNull(fstReamrk4),
                    StringUtils.getIsStringEqulesNull(fstReamrk5)};
            // sql = "update " + CLFindScheduleTable.CLFindScheduleTable +
            // " set "
            // + CLFindScheduleTable.fstFID + " = " + fstFID + ", "
            // + CLFindScheduleTable.fstSchID + " = " + fstSchID + ", "
            // + CLFindScheduleTable.fstType + " = " + fstType + ", "
            // + CLFindScheduleTable.fstBeforeTime + " = " + fstBeforeTime
            // + ", " + CLFindScheduleTable.fstIsAlarm + " = "
            // + fstIsAlarm + ", " + CLFindScheduleTable.fstDisplayTime
            // + " = " + fstDisplayTime + ", "
            // + CLFindScheduleTable.fstColorType + " = " + fstColorType
            // + ", " + CLFindScheduleTable.fstIsPostpone + " = "
            // + fstIsPostpone + ", " + CLFindScheduleTable.fstIsImportant
            // + " = '" + fstIsImportant + "', "
            // + CLFindScheduleTable.fstIsEnd + " = " + fstIsEnd + ", "
            // + CLFindScheduleTable.fstSourceType + " = " + fstSourceType
            // + ", " + CLFindScheduleTable.fstRepeatId + " = "
            // + fstRepeatId + ", " + CLFindScheduleTable.fstOpenState
            // + " = " + fstOpenState + ", "
            // + CLFindScheduleTable.fstRepeatLink + " = " + fstRepeatLink
            // + ", " + CLFindScheduleTable.fstRecommendId + " = "
            // + fstRecommendId + ", " + CLFindScheduleTable.fstIsRead
            // + " = " + fstIsRead + ", " + CLFindScheduleTable.fstAID
            // + " = " + fstAID + ", " + CLFindScheduleTable.fstIsPuase
            // + " = " + fstIsPuase + ", "
            // + CLFindScheduleTable.fstRepStateOne + " = "
            // + fstRepStateOne + ", "
            // + CLFindScheduleTable.fstRepStateTwo + " = "
            // + fstRepStateTwo + ", "
            // + CLFindScheduleTable.fstRepInStable + " = "
            // + fstRepInStable + ", " + CLFindScheduleTable.fstPostState
            // + " = " + fstPostState + ", "
            // + CLFindScheduleTable.fstRepType + " = " + fstRepType
            // + ", " + CLFindScheduleTable.fstAType + " = " + fstAType
            // + ", " + CLFindScheduleTable.fstUpdateState + " = "
            // + fstUpdateState + ", " + CLFindScheduleTable.fstParameter
            // + " = '" + fstParameter + "', "
            // + CLFindScheduleTable.fstContent + " = '" + content + "', "
            // + CLFindScheduleTable.fstDate + " = '" + fstDate + "', "
            // + CLFindScheduleTable.fstTime + " = '" + fstTime + "', "
            // + CLFindScheduleTable.fstRingCode + " = '" + fstRingCode
            // + "', " + CLFindScheduleTable.fstRingDesc + " ='"
            // + fstRingDesc + "', " + CLFindScheduleTable.fstTags
            // + " = '" + fstTags + "', "
            // + CLFindScheduleTable.fstSourceDesc + " = '"
            // + fstSourceDesc + "', "
            // + CLFindScheduleTable.fstSourceDescSpare + " = '"
            // + fstSourceDescSpare + "', "
            // + CLFindScheduleTable.fstRepeatDate + " = '"
            // + fstRepeatDate + "' , "
            // + CLFindScheduleTable.fstRepStartDate + " = '"
            // + fstRepStartDate + "' , "
            // + CLFindScheduleTable.fstRpNextCreatedTime + " = '"
            // + fstRpNextCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepLastCreatedTime + " = '"
            // + fstRepLastCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepInitialCreatedTime + " = '"
            // + fstRepInitialCreatedTime + "' , "
            // + CLFindScheduleTable.fstRepDateOne + " = '"
            // + fstRepDateOne + "' , "
            // + CLFindScheduleTable.fstRepDateTwo + " = '"
            // + fstRepDateTwo + "' , "
            // + CLFindScheduleTable.fstRecommendName + " = '"
            // + fstRecommendName + "' , " + CLFindScheduleTable.fstWebURL
            // + " = '" + fstWebURL + "' , "
            // + CLFindScheduleTable.fstImagePath + " = '" + fstImagePath
            // + "' , " + CLFindScheduleTable.fstParReamrk + " = '"
            // + fstParReamrk + "' , " + CLFindScheduleTable.fstCreateTime
            // + " = '" + fstCreateTime + "' , "
            // + CLFindScheduleTable.fstUpdateTime + " ='"
            // + fstUpdateTime + "' , " + CLFindScheduleTable.fstReamrk1
            // + " = '" + fstReamrk1 + "' , "
            // + CLFindScheduleTable.fstReamrk2 + " = '" + fstReamrk2
            // + "' , " + CLFindScheduleTable.fstReamrk3 + " ='"
            // + fstReamrk3 + "' , " + CLFindScheduleTable.fstReamrk4
            // + " = '" + fstReamrk4 + "' , "
            // + CLFindScheduleTable.fstReamrk5 + " = '" + fstReamrk5
            // + "' where " + CLFindScheduleTable.fstRepeatId + " = "
            // + fstRepeatId + " and "
            // + CLFindScheduleTable.fstUpdateState + " != " + 3;
        }
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public List<Map<String, String>> QueryNewFocusData(int type, int fstFID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;
        String yestoday;// 昨天
        String today;// 今天
        String tomorrow;// 明天
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);
        yestoday = DateUtil.formatDate(calendar.getTime());
        calendar.setTime(new Date());
        today = DateUtil.formatDate(calendar.getTime());
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) + 1);
        tomorrow = DateUtil.formatDate(calendar.getTime());
        String sql = "";
        switch (type) {
            case -1:// 上传重复数据查询 新增
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstUpdateState
                        + " = "
                        + 1
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 1
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case -2:// 上传重复数据查询修改
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstUpdateState
                        + " = "
                        + 2
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 1
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case -3:// 上传重复数据查询 删除
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstUpdateState
                        + " = "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 1
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case -4:// 上传日程数据查询 新增
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstUpdateState
                        + " = "
                        + 1
                        + " and ("
                        + CLFindScheduleTable.fstRepeatId
                        + " = "
                        + 0
                        + " or ("
                        + CLFindScheduleTable.fstRepeatId
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstRepeatLink
                        + " != "
                        + 1
                        + ")) order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case -5:// 上传日程数据查询 修改
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstUpdateState
                        + " = "
                        + 2
                        + " and ("
                        + CLFindScheduleTable.fstRepeatId
                        + " = "
                        + 0
                        + " or ("
                        + CLFindScheduleTable.fstRepeatId
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstRepeatLink
                        + " != "
                        + 1
                        + ")) order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case -6:// 上传日程数据查询删除
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstUpdateState
                        + " = "
                        + 3
                        + " and ("
                        + CLFindScheduleTable.fstRepeatId
                        + " = "
                        + 0
                        + " or ("
                        + CLFindScheduleTable.fstRepeatId
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstRepeatLink
                        + " != "
                        + 1
                        + ")) order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 0:
                sql = "select * from " + CLFindScheduleTable.CLFindScheduleTable
                        + " where " + CLFindScheduleTable.fstUpdateState + " != "
                        + 3 + " and " + CLFindScheduleTable.fstRepeatId + " = " + 0
                        + " order by repTime asc";
                break;
            case 1:// 今天
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + "fstDate =='"
                        + today
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 2:// 明天
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + "fstDate =='"
                        + tomorrow
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 3:// 明天之后的
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + "fstDate >'"
                        + tomorrow
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 4:// 昨天
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + "fstDate =='"
                        + yestoday
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 5:// 昨天之前
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + "fstDate <'"
                        + yestoday
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 6:// 查询表中母记事
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstRepeatId
                        + " != "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 1
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 7:// 以前+未结束+顺延+普通记事
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + "fstDate <'"
                        + today
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " and "
                        + CLFindScheduleTable.fstIsEnd
                        + " = "
                        + 0
                        + " and "
                        + CLFindScheduleTable.fstIsPostpone
                        + " = "
                        + 1
                        + " and ("
                        + CLFindScheduleTable.fstRepeatId
                        + " = "
                        + 0
                        + " or ("
                        + CLFindScheduleTable.fstRepeatId
                        + " !=0"
                        + " and "
                        + CLFindScheduleTable.fstRepeatLink
                        + " = "
                        + 0
                        + ")) order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 8:// 查询今后的所有数据
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " and "
                        + CLFindScheduleTable.fstDate
                        + " >='"
                        + today
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            case 9:// 查询今天之前的所有数据
                sql = "select * from "
                        + CLFindScheduleTable.CLFindScheduleTable
                        + " where "
                        + CLFindScheduleTable.fstFID
                        + " = "
                        + fstFID
                        + " and "
                        + CLFindScheduleTable.fstDate
                        + " < '"
                        + today
                        + "' and "
                        + CLFindScheduleTable.fstUpdateState
                        + " != "
                        + 3
                        + " and "
                        + CLFindScheduleTable.fstType
                        + " = "
                        + 0
                        + " order by fstDate asc,fstTime asc,fstDisplayTime asc,fstID asc";
                break;
            default:
                break;
        }
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(CLFindScheduleTable.fstID, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstID)));
                noticeMap.put(CLFindScheduleTable.fstType, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstType)));
                noticeMap.put(CLFindScheduleTable.fstSchID, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstSchID)));
                noticeMap.put(CLFindScheduleTable.fstFID, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstFID)));
                noticeMap
                        .put(CLFindScheduleTable.fstBeforeTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstBeforeTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstIsAlarm,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstIsAlarm)));
                noticeMap
                        .put(CLFindScheduleTable.fstDisplayTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstDisplayTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstColorType,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstColorType)));
                noticeMap
                        .put(CLFindScheduleTable.fstIsPostpone,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstIsPostpone)));
                noticeMap
                        .put(CLFindScheduleTable.fstIsImportant,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstIsImportant)));
                noticeMap.put(CLFindScheduleTable.fstIsEnd, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstIsEnd)));
                noticeMap
                        .put(CLFindScheduleTable.fstSourceType,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstSourceType)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepeatId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepeatId)));
                noticeMap
                        .put(CLFindScheduleTable.fstOpenState,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstOpenState)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepeatLink,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepeatLink)));
                noticeMap
                        .put(CLFindScheduleTable.fstRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRecommendId)));
                noticeMap
                        .put(CLFindScheduleTable.fstIsRead,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstIsRead)));
                noticeMap.put(CLFindScheduleTable.fstAID, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstAID)));
                noticeMap
                        .put(CLFindScheduleTable.fstIsPuase,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstIsPuase)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepStateOne,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepStateOne)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepStateTwo,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepStateTwo)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepInStable,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepInStable)));
                noticeMap
                        .put(CLFindScheduleTable.fstPostState,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstPostState)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepType,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepType)));
                noticeMap.put(CLFindScheduleTable.fstAType, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstAType)));
                noticeMap
                        .put(CLFindScheduleTable.fstUpdateState,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstUpdateState)));
                noticeMap
                        .put(CLFindScheduleTable.fstParameter,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstParameter)));
                noticeMap
                        .put(CLFindScheduleTable.fstContent,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstContent)));
                noticeMap.put(CLFindScheduleTable.fstDate, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstDate)));
                noticeMap.put(CLFindScheduleTable.fstTime, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstRingCode,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRingCode)));
                noticeMap
                        .put(CLFindScheduleTable.fstRingDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRingDesc)));
                noticeMap.put(CLFindScheduleTable.fstTags, cursor
                        .getString(cursor
                                .getColumnIndex(CLFindScheduleTable.fstTags)));
                noticeMap
                        .put(CLFindScheduleTable.fstSourceDesc,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstSourceDesc)));
                noticeMap
                        .put(CLFindScheduleTable.fstSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstSourceDescSpare)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepeatDate,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepeatDate)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepStartDate,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepStartDate)));
                noticeMap
                        .put(CLFindScheduleTable.fstRpNextCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRpNextCreatedTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepLastCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepLastCreatedTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepInitialCreatedTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepInitialCreatedTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepDateOne,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepDateOne)));
                noticeMap
                        .put(CLFindScheduleTable.fstRepDateTwo,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRepDateTwo)));
                noticeMap
                        .put(CLFindScheduleTable.fstRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstRecommendName)));
                noticeMap
                        .put(CLFindScheduleTable.fstWebURL,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstWebURL)));
                noticeMap
                        .put(CLFindScheduleTable.fstImagePath,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstImagePath)));
                noticeMap
                        .put(CLFindScheduleTable.fstParReamrk,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstParReamrk)));
                noticeMap
                        .put(CLFindScheduleTable.fstCreateTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstCreateTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstUpdateTime,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstUpdateTime)));
                noticeMap
                        .put(CLFindScheduleTable.fstReamrk1,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstReamrk1)));
                noticeMap
                        .put(CLFindScheduleTable.fstReamrk2,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstReamrk2)));
                noticeMap
                        .put(CLFindScheduleTable.fstReamrk3,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstReamrk3)));
                noticeMap
                        .put(CLFindScheduleTable.fstReamrk4,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstReamrk4)));
                noticeMap
                        .put(CLFindScheduleTable.fstReamrk5,
                                cursor.getString(cursor
                                        .getColumnIndex(CLFindScheduleTable.fstReamrk5)));
                dataList.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataList;
    }

    /**
     * 查询数据库中是否有相同数据
     *
     * @return
     */
    public int CheckCountFromFocusShareData(int fstType, int fstSchID,
                                            int fstFID, int fstRepeatId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int result = 0;
        String sql = "";
        if (fstType == 0) {
            sql = "select count(*) from "
                    + CLFindScheduleTable.CLFindScheduleTable + " where "
                    + CLFindScheduleTable.fstSchID + " = " + fstSchID + " and "
                    + CLFindScheduleTable.fstFID + " = " + fstFID + " and "
                    + CLFindScheduleTable.fstRepeatId + " = " + 0;
        } else {
            sql = "select count(*) from "
                    + CLFindScheduleTable.CLFindScheduleTable + " where "
                    + CLFindScheduleTable.fstRepeatId + " = " + fstRepeatId
                    + " and " + CLFindScheduleTable.fstFID + " = " + fstFID;
        }
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            if (null != cursor && cursor.getCount() > 0) {
                cursor.moveToFirst();
                result = cursor.getInt(0);
                cursor.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            result = 0;
        }
        return result;
    }

    /**
     * 删除本地发现分享的数据
     */
    public void deleteNewFocusShareData(int type, int fstFID, int fstSchID,
                                        int fstRepeatId, String fstRepeatDate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "";
        if (type == 0) {// 删除日程
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstFID + " = " + fstFID
                    + " and " + CLFindScheduleTable.fstSchID + " = " + fstSchID
                    + " and " + CLFindScheduleTable.fstUpdateState + " != " + 3
                    + " and " + CLFindScheduleTable.fstRepeatId + " = " + 0;
        } else if (type == 4) {// 删除日程 实际是修改
            sql = "update " + CLFindScheduleTable.CLFindScheduleTable + " set "
                    + CLFindScheduleTable.fstUpdateState + " = " + 3
                    + " where " + CLFindScheduleTable.fstFID + " = " + fstFID
                    + " and " + CLFindScheduleTable.fstSchID + " = " + fstSchID
                    + " and " + CLFindScheduleTable.fstUpdateState + " != " + 3
                    + " and " + CLFindScheduleTable.fstRepeatId + " = " + 0;
        } else if (type == 5) {// 删除控件ID相同的重复子记事
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstFID + " = " + fstFID
                    + " and " + CLFindScheduleTable.fstSchID + " = " + fstSchID
                    + " and " + CLFindScheduleTable.fstUpdateState + " != " + 3
                    + " and " + CLFindScheduleTable.fstRepeatId + " = "
                    + fstRepeatId;
        } else if (type == 1) {// 删除重复
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstFID + " = " + fstFID
                    + " and " + CLFindScheduleTable.fstRepeatId + " = "
                    + fstRepeatId + " and "
                    + CLFindScheduleTable.fstUpdateState + " != " + 3;
        } else if (type == 2) {// 删除重复子记事
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstFID + " = " + fstFID
                    + " and " + CLFindScheduleTable.fstRepeatId + " = "
                    + fstRepeatId + " and " + CLFindScheduleTable.fstSchID
                    + " < " + 0 + " and " + CLFindScheduleTable.fstType + " = "
                    + 0 + " and " + CLFindScheduleTable.fstRepeatLink + " = "
                    + 1 + " and " + CLFindScheduleTable.fstUpdateState + " != "
                    + 3;
        } else if (type == 6) {// 删除网上同步成功后数据
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstSchID + " = "
                    + fstSchID + " and " + CLFindScheduleTable.fstType + " = "
                    + 0 + " and " + CLFindScheduleTable.fstRepeatId + " = " + 0;
        } else if (type == 7) {// 删除网上同步成功后的重复母记事
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstRepeatId + " = "
                    + fstRepeatId + " and " + CLFindScheduleTable.fstType
                    + " = " + 1 + " and " + CLFindScheduleTable.fstRepeatId
                    + " != " + 0;
        } else if (type == 8) {// 删除网上同步成功后的重复子记事
            sql = "delete from " + CLFindScheduleTable.CLFindScheduleTable
                    + " where " + CLFindScheduleTable.fstRepeatId + " = "
                    + fstRepeatId + " and " + CLFindScheduleTable.fstSchID
                    + " < " + 0 + " and " + CLFindScheduleTable.fstType + " = "
                    + 0 + " and " + CLFindScheduleTable.fstRepeatLink + " = "
                    + 1;
        } else if (type == 9) {// 修改重复状态为删除状态
            sql = "update " + CLFindScheduleTable.CLFindScheduleTable + " set "
                    + CLFindScheduleTable.fstUpdateState + " = " + 3
                    + " where " + CLFindScheduleTable.fstFID + " = " + fstFID
                    + " and " + CLFindScheduleTable.fstRepeatId + " = "
                    + fstRepeatId + " and " + CLFindScheduleTable.fstType
                    + " = " + 1 + " and " + CLFindScheduleTable.fstUpdateState
                    + " != " + 3;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 过期未结束顺延修改日期
     */
    public void updateNewFocusShareDate(int fstFID, int fstSchID, String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLFindScheduleTable.CLFindScheduleTable
                + " set " + CLFindScheduleTable.fstDate + " = '" + date
                + "' , " + CLFindScheduleTable.fstUpdateState + " = " + 0
                + " where " + CLFindScheduleTable.fstSchID + " = " + fstSchID
                + " and " + CLFindScheduleTable.fstFID + " = " + fstFID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
     * 子记事进行操作，修改母记事
     */
    public void updateNewFocusShareRepeatData(int fstFID, int repId,
                                              String repDateOne, String repDateTwo, int repStateOne,
                                              int repStateTwo) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + CLFindScheduleTable.CLFindScheduleTable
                + " set " + CLFindScheduleTable.fstUpdateState + " = " + 2
                + " , " + CLFindScheduleTable.fstRepDateOne + " = '"
                + repDateOne + "', " + CLFindScheduleTable.fstRepDateTwo
                + " = '" + repDateTwo + "', "
                + CLFindScheduleTable.fstRepStateOne + " = " + repStateOne
                + ", " + CLFindScheduleTable.fstRepStateTwo + " = "
                + repStateTwo + " " + " where " + CLFindScheduleTable.fstFID
                + " = " + fstFID + " and " + CLFindScheduleTable.fstRepeatId
                + " = " + repId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /*
     * 修改新版发现分享中同步成功后的状态
     */
    public void updateNewFocusShareStateData(int type, int oldfstSchID,
                                             int newfstSchID, int oldfstRepeatID, int newfstRepeatID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "";
        if (type == 0) {//日程
            sql = "update " + CLFindScheduleTable.CLFindScheduleTable + " set "
                    + CLFindScheduleTable.fstUpdateState + " = " + 0 + " , "
                    + CLFindScheduleTable.fstSchID + " = " + newfstSchID
                    + " where " + CLFindScheduleTable.fstSchID + " = "
                    + oldfstSchID + " and "
                    + CLFindScheduleTable.fstUpdateState + " != " + 0;
        } else if (type == 1) {// 重复
            sql = "update " + CLFindScheduleTable.CLFindScheduleTable + " set "
                    + CLFindScheduleTable.fstUpdateState + " = " + 0 + " , "
                    + CLFindScheduleTable.fstRepeatId + " = " + newfstRepeatID
                    + " where " + CLFindScheduleTable.fstRepeatId + " = "
                    + oldfstRepeatID + " and "
                    + CLFindScheduleTable.fstUpdateState + " != " + 0;
        } else if (type == 3) {// 修改重复子记事
            sql = "update " + CLFindScheduleTable.CLFindScheduleTable + " set "
                    + CLFindScheduleTable.fstUpdateState + " = " + 0 + " , "
                    + CLFindScheduleTable.fstRepeatId + " = " + newfstRepeatID
                    + " where " + CLFindScheduleTable.fstRepeatId + " = "
                    + oldfstRepeatID + " and "
                    + CLFindScheduleTable.fstUpdateState + " = " + 0 + " and "
                    + CLFindScheduleTable.fstType + " = " + 0 + " and "
                    + CLFindScheduleTable.fstRepeatLink + " = " + 1;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
//		CrashReport.testJavaCrash();
    }
    //*********************************************新版好友列表操作*************************************************//
    /**
     * 发出表
     */
    public static String FriendsListTableSQL = "CREATE TABLE if not exists FriendsListTable (" +
            "uid varchar NOT NULL," +
            "id integer NOT NULL," +
            "cpId varchar PRIMARY KEY NOT NULL," +
            "uPersontag varchar NOT NULL," +
            "uToCode varchar NOT NULL," +
            "remark varchar(500) NOT NULL," +
            "uPortrait varchar(50) NOT NULL," +
            "dateUpdate varchar(50) NOT NULL," +
            "uNickName varchar(50) NOT NULL," +
            "type varchar(10) NOT NULL," +
            "uBackgroundImage char(50) NOT NULL" +
            ")";

    /**
     * 发出日程表
     */
    public static String FriendDownAllScheduleBeanSQL = "CREATE TABLE if not exists FriendDownAllScheduleBean (" +
            "  CAlarmsound varchar(100) NOT NULL," +
            "  CAlarmsoundDesc varchar(200) NOT NULL," +
            "  CLightAppId integer(500) NOT NULL DEFAULT(0)," +
            "  COpenstate integer(100) NOT NULL DEFAULT(0)," +
            "  CPostpone integer(100) NOT NULL DEFAULT(0)," +
            "  CRecommendName varchar(100) NOT NULL," +
            "  CTags varchar(500) NOT NULL," +
            "  CType integer(100) NOT NULL," +
            "  CTypeDesc varchar(500) NOT NULL," +
            "  CTypeSpare varchar(500) NOT NULL," +
            "  atype integer(100) NOT NULL DEFAULT(0)," +
            "  calendaId integer NOT NULL," +
            "  cbeforTime integer(100) NOT NULL DEFAULT(0)," +
            "  cdate datetime(100) NOT NULL," +
            "  changTime datetime(100) NOT NULL," +
            "  cisAlarm integer(100) NOT NULL DEFAULT(0)," +
            "  cpId integer(100) NOT NULL DEFAULT(0)," +
            "  cretetime datetime(100) NOT NULL," +
            "  ctime datetime(100) NOT NULL," +
            "  downNum datetime(100) NOT NULL," +
            "  downstate integer(100) NOT NULL DEFAULT(0)," +
            "  endNum integer(100) NOT NULL DEFAULT(0)," +
            "  endState integer(100) NOT NULL DEFAULT(0)," +
            "  id integer PRIMARY KEY NOT NULL," +
            "  imgPath varchar(500) NOT NULL," +
            "  lyNum integer(100) NOT NULL DEFAULT(0)," +
            "  message text NOT NULL," +
            "  parReamrk varchar(500) NOT NULL," +
            "  pid integer NOT NULL DEFAULT(0)," +
            "  poststate integer(100) NOT NULL DEFAULT(0)," +
            "  remark varchar(1000) NOT NULL," +
            "  remark1 varchar(1000) NOT NULL," +
            "  remark2 varchar(1000) NOT NULL," +
            "  remark3 varchar(1000) NOT NULL," +
            "  repCalendaState integer(100) NOT NULL DEFAULT(0)," +
            "  repCalendaTime datetime(100) NOT NULL," +
            "  repColorType integer(100) NOT NULL DEFAULT(0)," +
            "  repDisplayTime datetime(100) NOT NULL," +
            "  repInStable integer(100) NOT NULL DEFAULT(0)," +
            "  repIsPuase integer(100) NOT NULL DEFAULT(0)," +
            "  repState largeint(100) NOT NULL," +
            "  repType integer(100) NOT NULL DEFAULT(0)," +
            "  repTypeParameter varchar(500) NOT NULL," +
            "  repdatetwo varchar(500) NOT NULL," +
            "  repinitialcreatedtime datetime(100) NOT NULL," +
            "  replastcreatedtime datetime(100) NOT NULL," +
            "  repnextcreatedtime datetime(100) NOT NULL," +
            "  repstartdate varchar(1000) NOT NULL," +
            "  repstatetwo integer(100) NOT NULL DEFAULT(0)," +
            "  schIsImportant integer(100) NOT NULL DEFAULT(0)," +
            "  status integer(100) NOT NULL DEFAULT(0)," +
            "  uid integer(100) NOT NULL DEFAULT(0)," +
            "  webUrl varchar(500) NOT NULL" +
            ")";

    public static String FriendCommonReply = "CREATE TABLE if not exists FriendCommonReply (" +
            "  id integer PRIMARY KEY AUTOINCREMENT NOT NULL," +
            "  message text NOT NULL" +
            ")";

    public static String CLCommentTableSQL = "CREATE TABLE if not exists CLCommentTable (" +
            "cmtMessageID integer PRIMARY KEY NOT NULL DEFAULT(0)," +
            "cmtUserID INTEGER NOT NULL DEFAULT 0," +
            "cmtFscID INTEGER NOT NULL DEFAULT 0," +
            "cmtSchID INTEGER NOT NULL DEFAULT 0," +
            "cmtType INTEGER NOT NULL DEFAULT 0," +
            "cmtAType INTEGER NOT NULL DEFAULT 0," +
            "cmtIsNew INTEGER NOT NULL DEFAULT 0," +
            "cmtContent TEXT NOT NULL DEFAULT ''," +
            "cmtSchContent VARCHAR(4000,0) NOT NULL DEFAULT ''," +
            "cmtNickName VARCHAR(800,0) NOT NULL DEFAULT ''," +
            "cmtSendName VARCHAR(800,0) NOT NULL DEFAULT ''," +
            "cmtHeaderImage VARCHAR(800,0) NOT NULL DEFAULT ''," +
            "cmtBackImage VARCHAR(800,0) NOT NULL DEFAULT ''," +
            "cmtImages VARCHAR(2000,0) NOT NULL DEFAULT ''," +
            "cmtWebURL VARCHAR(2000,0) NOT NULL DEFAULT ''," +
            "cmtVedio VARCHAR(2000,0) NOT NULL DEFAULT ''," +
            "cmtFilePath VARCHAR(2000,0) NOT NULL DEFAULT ''," +
            "cmtRemark VARCHAR(4000,0) NOT NULL DEFAULT ''," +
            "cmtRemark1 VARCHAR(4000,0) NOT NULL DEFAULT ''," +
            "cmtRemark2 VARCHAR(4000,0) NOT NULL DEFAULT ''," +
            "cmtRemark3 VARCHAR(4000,0) NOT NULL DEFAULT ''," +
            "cmtOperateTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP," +
            "cmtCreateTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,cmtNewType integer NOT NULL DEFAULT(0)" +
            ")";

    public static String CLInventoryModelTableSQL = "CREATE TABLE if not exists CLInventoryModelTable (" +
            "invID INTEGER DEFAULT 0," +
            "invUID INTEGER DEFAULT 0," +
            "invTitleID String DEFAULT ''," +
            "invTick INTEGER DEFAULT 0," +
            "invOrderIndex INTEGER DEFAULT 0," +
            "invUpdateState INTEGER DEFAULT 0," +
            "invType INTEGER DEFAULT 0," +
            "invStyle INTEGER DEFAULT 0," +
            "invPasteStyle INTEGER DEFAULT 0," +
            "invStockInteger0 INTEGER DEFAULT 0," +
            "invStockInteger1 INTEGER DEFAULT 0," +
            "invStockInteger2 INTEGER DEFAULT 0," +
            "invStockInteger3 INTEGER DEFAULT 0," +
            "invContent TEXT DEFAULT ''," +
            "invTitle VARCHAR(4000,0) DEFAULT ''," +
            "invUpdateTime datetime DEFAULT CURRENT_TIMESTAMP," +
            "invCreateTime datetime DEFAULT CURRENT_TIMESTAMP," +
            "invImagePath VARCHAR(2000,0) DEFAULT ''," +
            "invImageURL VARCHAR(2000,0) DEFAULT ''," +
            "invTitleImage VARCHAR(2000,0) DEFAULT ''," +
            "invWebURL VARCHAR(2000,0) DEFAULT ''," +
            "invDescribe VARCHAR(2000,0) DEFAULT ''," +
            "invRemark VARCHAR(4000,0) DEFAULT ''," +
            "invRemark1 VARCHAR(4000,0) DEFAULT ''," +
            "invRemark2 VARCHAR(4000,0) DEFAULT ''," +
            "invRemark3 VARCHAR(4000,0) DEFAULT ''," +
            "invRemark4 VARCHAR(4000,0) DEFAULT ''," +
            "PRIMARY KEY(invID)" +
            ");";

    public static String tb_user_detail_list_type = "CREATE TABLE if not exists tb_user_detail_list_type (" +
            "  id int(11)  DEFAULT('0')," +
            "  uid int(11) DEFAULT('0')," +
            "  content varchar(100) DEFAULT(NULL)," +
            "  orderId int(11) DEFAULT('0')," +
            "  changeTime datetime DEFAULT(NULL)," +
            "  localId int(11) PRIMARY KEY NOT NULL," +
            "  remark varchar(50) DEFAULT(NULL)," +
            "  remark1 varchar(50) DEFAULT(NULL)," +
            "  styleId int(11) DEFAULT('0')," +
            "  updatestate integer(128) DEFAULT(0)" +
            ")";

    //清单标题表
    public static String tb_user_detail_list_title = "CREATE TABLE if not exists tb_user_detail_list_title (" +
            "  id integer NOT NULL DEFAULT(0)," +
            "  titleId varchar PRIMARY KEY NOT NULL DEFAULT('0')," +
            "  uid integer NOT NULL DEFAULT(0)," +
            "  titles varchar NOT NULL," +
            "  imgPath varchar," +
            "  imgUrl varchar," +
            "  shareUrl varchar," +
            "  filed varchar," +
            "  nums varchar," +
            "  copys varchar DEFAULT('1')," +
            "  styles integer DEFAULT(0)," +
            "  ltype integer DEFAULT(0)," +
            "  orderId integer DEFAULT(0)," +
            "  createTime varchar datetime DEFAULT CURRENT_TIMESTAMP," +
            "  changeTime varchar datetime DEFAULT CURRENT_TIMESTAMP," +
            "  localTimes varchar datetime DEFAULT CURRENT_TIMESTAMP," +
            "  remark varchar DEFAULT('1')," +
            "  remark1 varchar DEFAULT('0')," +
            "  remark2 varchar DEFAULT('0')," +
            "  remark3 varchar DEFAULT('0')," +
            "  other1 varchar NOT NULL DEFAULT('0')," +
            "  other2 varchar NOT NULL DEFAULT('0')," +
            "  other3 varchar," +
            "  other4 varchar," +
            "  other5 varchar," +
            "  updatestate integer NOT NULL DEFAULT(0)," +
            "  puid integer NOT NULL DEFAULT(0)," +
            "  pname varchar," +
            "  states integer DEFAULT(0)," +
            "  sends integer DEFAULT(0)," +
            "  openState integer NOT NULL DEFAULT(0)" +
            ");";
    //清单详情表
    public static String tb_user_detail_list_class1 = "CREATE TABLE if not exists tb_user_detail_list_class1 (" +
            "  id integer PRIMARY KEY NOT NULL DEFAULT(0)," +
            "  uid integer NOT NULL DEFAULT(0)," +
            "  contents varchar," +
            "  changeTime varchar DEFAULT CURRENT_TIMESTAMP," +
            "  remark varchar," +
            "  orderId integer NOT NULL DEFAULT(0)," +
            "  titles varchar," +
            "  imgPath varchar," +
            "  imgUrl varchar," +
            "  createTime varchar DEFAULT CURRENT_TIMESTAMP," +
            "  lType integer NOT NULL DEFAULT(0)," +
            "  remark1 varchar," +
            "  remark2 varchar," +
            "  style integer NOT NULL DEFAULT(0)," +
            "  endstate integer NOT NULL DEFAULT(1)," +
            "  titleId varchar NOT NULL DEFAULT('0')," +
            "  nums varchar NOT NULL DEFAULT('0')," +
            "  cpath varchar," +
            "  curl varchar," +
            "  shareUrl varchar," +
            "  remark3 varchar," +
            "  remark4 varchar," +
            "  other varchar," +
            "  other1 varchar," +
            "  other2 varchar," +
            "  updatestate integer NOT NULL DEFAULT(0)" +
            ");";

    public static String tb_newfriend = "CREATE TABLE if not exists NewFriendTable (" +
            "  puid integer PRIMARY KEY NOT NULL DEFAULT(0)," +
            "  uid integer NOT NULL DEFAULT(0)," +
            "  id integer NOT NULL DEFAULT(0)," +
            "  type integer NOT NULL DEFAULT(0)," +
            "  pname varchar(100,0) NOT NULL DEFAULT('')," +
            "  pimgs varchar(100,0) NOT NULL DEFAULT('')," +
            "  changeTime datetime NOT NULL DEFAULT('')," +
            "  createTime datetime NOT NULL DEFAULT('')," +
            "  remark varchar(200,0) NOT NULL DEFAULT('')," +
            "  remark1 varchar(200,0) NOT NULL DEFAULT('')," +
            "  updatastate integer(128) NOT NULL DEFAULT(0)" +
            ");";

    public static String tb_timepreinstall_recommend_type = "CREATE TABLE if not exists tb_timepreinstall_recommend_type (" +
            "  id int(11) PRIMARY KEY NOT NULL," +
            "  name varchar(100) DEFAULT(NULL)," +
            "  titleImg varchar(100) DEFAULT(NULL)," +
            "  createTime datetime DEFAULT(NULL)," +
            "  introduction varchar(100) DEFAULT(NULL)," +
            "  remark varchar(50) DEFAULT(NULL)," +
            "  orderby int(11) DEFAULT('0')" +
            ");";

    public static String tb_timepreinstal_recommend_type_content = "CREATE TABLE if not exists tb_timepreinstal_recommend_type_content (" +
            "  id int(11) PRIMARY KEY NOT NULL," +
            "  repTime varchar(50) DEFAULT(NULL)," +
            "  repType int(11) DEFAULT('0')," +
            "  repTypeParameter varchar(200) DEFAULT('0')," +
            "  repRingDesc varchar(50) DEFAULT(NULL)," +
            "  repRingCode varchar(50) DEFAULT(NULL)," +
            "  repUid int(11) DEFAULT(NULL)," +
            "  ctype int(11) DEFAULT('0')," +
            "  repContent varchar(4000) DEFAULT(NULL)," +
            "  createTime datetime DEFAULT(NULL)," +
            "  recommendName varchar(50) DEFAULT(NULL)," +
            "  collectionCount int(11) DEFAULT('0')," +
            "  remark varchar(50) DEFAULT(NULL)," +
            "  remark1 varchar(50) DEFAULT(NULL)" +
            ");";
    //日程清楚附表
    public static String calndernote = "CREATE TABLE if not exists CalenderNote (" +
            "  titleid varchar PRIMARY KEY NOT NULL DEFAULT('0')," +
            "  nums varchar NOT NULL DEFAULT('0')," +
            "  remark char," +
            "  remark1 char," +
            "  remark2 char," +
            "  remark3 char," +
            "  remark4 char," +
            "  remark5 char," +
            "  remark6 char," +
            "  remark7 char(128)" +
            ");";

    public static String tb_user_detail_ly = "CREATE TABLE if not exists tb_user_detail_ly (" +
            "  id int PRIMARY KEY NOT NULL," +
            "  lyUid int NOT NULL DEFAULT('0')," +
            "  lyName varchar NOT NULL DEFAULT('')," +
            "  lyTitleImg varchar NOT NULL DEFAULT('')," +
            "  cId int NOT NULL DEFAULT('0')," +
            "  mess varchar NOT NULL DEFAULT('')," +
            "  uid int NOT NULL DEFAULT('0')," +
            "  titleId varchar NOT NULL DEFAULT('0')," +
            "  localTimes datetime NOT NULL," +
            "  changeTime datetime NOT NULL," +
            "  type int NOT NULL DEFAULT('0')," +
            "  reamrk varchar NOT NULL DEFAULT('')," +
            "  reamrk1 varchar NOT NULL DEFAULT('')," +
            "  reamrk2 varchar NOT NULL DEFAULT('')," +
            "  other varchar NOT NULL DEFAULT('0')," +
            "  other1 datetime NOT NULL DEFAULT('')," +
            "  other2 varchar DEFAULT('')," +
            "  other3 varchar DEFAULT('')," +
            "  other4 varchar DEFAULT('')," +
            "  updatestate int NOT NULL DEFAULT(0)" +
            ");";

    public static String tb_calendar_list_class1 = "CREATE TABLE if not exists tb_calendar_list_class1 (" +
            "  id int(11) PRIMARY KEY NOT NULL," +
            "  uid int(11) NOT NULL," +
            "  titleId varchar(50) NOT NULL DEFAULT('')," +
            "  titles varchar(200) NOT NULL DEFAULT('')," +
            "  contents varchar(1000) NOT NULL DEFAULT('')," +
            "  changeTime datetime NOT NULL," +
            "  orderId int(11) DEFAULT('0')," +
            "  imgPath varchar(200) DEFAULT('')," +
            "  imgUrl varchar(200) DEFAULT('')," +
            "  createTime datetime NOT NULL," +
            "  lType int(11) DEFAULT('0')," +
            "  style int(11) DEFAULT('0')," +
            "  endstate int(11) NOT NULL DEFAULT('1')," +
            "  nums varchar(50) DEFAULT('0')," +
            "  cpath varchar(200) DEFAULT('')," +
            "  curl varchar(200) DEFAULT('')," +
            "  shareUrl varchar(200) DEFAULT('')," +
            "  sdesc varchar(100) DEFAULT('')," +
            "  localIds varchar(50) NOT NULL DEFAULT('0')," +
            "  remark varchar(50) DEFAULT(NULL)," +
            "  remark1 varchar(50) DEFAULT(NULL)," +
            "  remark2 varchar(50) DEFAULT(NULL)," +
            "  remark3 varchar(200) DEFAULT(NULL)," +
            "  remark4 varchar(200) DEFAULT(NULL)," +
            "  remark5 varchar(50) DEFAULT(NULL)," +
            "  remark6 varchar(50) DEFAULT(NULL),updatestate integer(128) NOT NULL DEFAULT(0)" +
            ")";

    public static String tb_user_frends_task = "CREATE TABLE if not exists tb_user_frends_task (" +
            "  id int(11) PRIMARY KEY NOT NULL," +
            "  uId int(11) NOT NULL DEFAULT(0)," +
            "  ctype int(11) NOT NULL DEFAULT(0)," +
            "  ptype int(11) NOT NULL DEFAULT(0)," +
            "  uname varchar(50) NOT NULL DEFAULT('')," +
            "  pname varchar(50) NOT NULL DEFAULT('')," +
            "  titleImg varchar(50) NOT NULL DEFAULT('')," +
            "  puId int(11) NOT NULL DEFAULT(0)," +
            "  pDeleState int(11) NOT NULL DEFAULT(0)," +
            "  content varchar(500) NOT NULL DEFAULT('')," +
            "  cdate varchar(50) NOT NULL DEFAULT('')," +
            "  ctime varchar(50) NOT NULL DEFAULT('')," +
            "  repInSTable int(11) NOT NULL DEFAULT(0)," +
            "  repType int(11) NOT NULL DEFAULT(1)," +
            "  repTypeParameter varchar(50) DEFAULT(NULL)," +
            "  cIsAlarm varchar(50) DEFAULT(NULL)," +
            "  cBeforTime int(11) NOT NULL DEFAULT(0)," +
            "  cAlarmSound varchar(50) DEFAULT(NULL)," +
            "  cAlarmSoundDesc varchar(50) DEFAULT(NULL)," +
            "  cDisplayAlarm int(11) NOT NULL DEFAULT(0)," +
            "  cPostpone int(11) NOT NULL DEFAULT(0)," +
            "  cImportant int(11) NOT NULL DEFAULT(0)," +
            "  pIsEnd int(11) NOT NULL DEFAULT(0)," +
            "  cIsEnd int(11) NOT NULL DEFAULT(0)," +
            "  styles int(11) NOT NULL DEFAULT(0)," +
            "  cIsDown int(11) NOT NULL DEFAULT(1)," +
            "  cColorType int(11) NOT NULL DEFAULT(0)," +
            "  createTime datetime NOT NULL DEFAULT('')," +
            "  changTime datetime NOT NULL DEFAULT('')," +
            "  titleId varchar(50) NOT NULL DEFAULT('')," +
            "  remark varchar(50) DEFAULT('')," +
            "  remark1 varchar(50) DEFAULT('')," +
            "  remark2 varchar(50) DEFAULT('')," +
            "  remark3 varchar(50) DEFAULT(NULL)," +
            "  remark4 varchar(50) DEFAULT(NULL)," +
            "  remark5 varchar(50) DEFAULT(NULL)," +
            "  remark6 varchar(50) DEFAULT(NULL),updatestate integer(128) DEFAULT(0)" +
            ");";
    public static String tb_user_frends_task_class1 = "CREATE TABLE if not exists tb_user_frends_task_class1 (" +
            "  id int(11) PRIMARY KEY NOT NULL," +
            "  uId int(11) NOT NULL DEFAULT(0)," +
            "  puId int(11) NOT NULL DEFAULT(0)," +
            "  ctype int(11) NOT NULL DEFAULT(0)," +
            "  titleId varchar(50) NOT NULL DEFAULT(0)," +
            "  titles varchar(200) NOT NULL DEFAULT('')," +
            "  contents varchar(1000) NOT NULL DEFAULT('')," +
            "  changeTime datetime NOT NULL DEFAULT('')," +
            "  orderId int(11) NOT NULL DEFAULT(0)," +
            "  imgPath varchar(200) DEFAULT(NULL)," +
            "  imgUrl varchar(200) DEFAULT(NULL)," +
            "  createTime datetime NOT NULL DEFAULT('')," +
            "  lType int(11) NOT NULL DEFAULT(0)," +
            "  style int(11) NOT NULL DEFAULT(0)," +
            "  endstate int(11) NOT NULL DEFAULT(1)," +
            "  nums varchar(50) NOT NULL DEFAULT(0)," +
            "  cpath varchar(200) DEFAULT(NULL)," +
            "  curl varchar(200) DEFAULT(NULL)," +
            "  shareUrl varchar(200) DEFAULT(NULL)," +
            "  sdesc varchar(100) DEFAULT(NULL)," +
            "  localIds varchar(50) NOT NULL DEFAULT(0)," +
            "  remark varchar(50) DEFAULT(NULL)," +
            "  remark1 varchar(50) DEFAULT(NULL)," +
            "  remark2 varchar(50) DEFAULT(NULL)," +
            "  remark3 varchar(200) DEFAULT(NULL)," +
            "  remark4 varchar(200) DEFAULT(NULL)," +
            "  remark5 varchar(50) DEFAULT(NULL)," +
            "  remark6 varchar(50) DEFAULT(NULL)," +
            "  remark7 varchar(50) DEFAULT(NULL)," +
            "  remark8 varchar(50) DEFAULT(NULL),updatestate integer(128) DEFAULT(0)" +
            ");";

    public static String tb_function_my = "CREATE TABLE if not exists tb_function_my (" +
            "  id integer PRIMARY KEY NOT NULL," +
            "  name varchar NOT NULL DEFAULT('')," +
            "  image varchar NOT NULL DEFAULT('')," +
            "  type integer NOT NULL DEFAULT(0)," +
            "  url varchar NOT NULL DEFAULT('')," +
            "  androidDownLoadUrl varchar NOT NULL DEFAULT('')," +
            "  androidUrl varchar NOT NULL DEFAULT('')," +
            "  iosDownLoadUrl varchar NOT NULL DEFAULT('')," +
            "  iosUrl varchar NOT NULL DEFAULT('')," +
            "  hotType integer NOT NULL DEFAULT(0)," +
            "  orderIndex integer NOT NULL DEFAULT('')," +
            "  createTime varchar NOT NULL DEFAULT('')," +
            "  urlType integer NOT NULL DEFAULT(0)," +
            "  appType integer NOT NULL DEFAULT(0)," +
            "  updateTime varchar NOT NULL DEFAULT('')," +
            "  repType int DEFAULT(0)," +
            "  repTypeParameter varchar(50) DEFAULT('')," +
            "  remark1 varchar(50) DEFAULT('0')," +
            "  remark2 varchar(50) DEFAULT('')," +
            "  remark3 varchar(50) DEFAULT('')," +
            "  remark4 varchar(50) DEFAULT('1')" +
            ");";

    public static String ScheduleTable_sql = "CREATE TABLE if not exists ScheduleTable (" +
            "  ID integer PRIMARY KEY NOT NULL," +
            "  schID integer NOT NULL DEFAULT(0)," +
            "  schContent varchar(4000,0) NOT NULL DEFAULT('')," +
            "  schDate varchar(50,0) NOT NULL DEFAULT('')," +
            "  schTime varchar(50,0) NOT NULL DEFAULT('')," +
            "  schIsAlarm integer NOT NULL DEFAULT(0)," +
            "  schBeforeTime integer NOT NULL DEFAULT(0)," +
            "  schDisplayTime integer NOT NULL DEFAULT(0)," +
            "  schIsPostpone integer NOT NULL DEFAULT(0)," +
            "  schIsImportant integer NOT NULL DEFAULT(0)," +
            "  schColorType integer NOT NULL DEFAULT(0)," +
            "  schIsEnd integer NOT NULL DEFAULT(0)," +
            "  schCreateTime datetime NOT NULL DEFAULT(CURRENT_TIMESTAMP)," +
            "  schTags varchar(100,0) NOT NULL DEFAULT('')," +
            "  schSourceType integer NOT NULL DEFAULT(0)," +
            "  schSourceDesc varchar(500,0) NOT NULL DEFAULT('')," +
            "  schSourceDescSpare varchar(500,0) NOT NULL DEFAULT('')," +
            "  schRepeatID integer NOT NULL DEFAULT(0)," +
            "  schRepeatDate varchar(50,0) NOT NULL DEFAULT('')," +
            "  schUpdateTime datetime NOT NULL DEFAULT(CURRENT_TIMESTAMP)," +
            "  schUpdateState integer NOT NULL DEFAULT(0)," +
            "  schOpenState integer NOT NULL DEFAULT(0)," +
            "  schRepeatLink integer DEFAULT(0)," +
            "  schRingDesc varchar(100) DEFAULT('')," +
            "  schRingCode varchar(100) DEFAULT('')," +
            "  schcRecommendName varchar(100)," +
            "  schRead integer DEFAULT(0)," +
            "  schAID integer DEFAULT(0)," +
            "  schAType integer DEFAULT(0)," +
            "  schWebURL varchar(200) DEFAULT('')," +
            "  schImagePath varchar(500) DEFAULT('')," +
            "  schFocusState integer DEFAULT(0)," +
            "  schFriendID integer DEFAULT(0)," +
            "  schcRecommendId integer DEFAULT(0)," +
            "  schpisEnd integer NOT NULL DEFAULT(0)," +
            "  schRemark1 varchar DEFAULT('0')," +
            "  schRemark2 varchar," +
            "  schRemark3 varchar," +
            "  schRemark4 varchar," +
            "  schRemark5 varchar" +
            ");";

    public static String tb_timepreinstall_list_class1 = "CREATE TABLE if not exists tb_timepreinstall_list_class1 (" +
            "  id int(11) PRIMARY KEY NOT NULL," +
            "  uid int(11) NOT NULL DEFAULT('0')," +
            "  cdate varchar(50) NOT NULL DEFAULT('0')," +
            "  ctime varchar(50) NOT NULL DEFAULT('0')," +
            "  titleId varchar(50) NOT NULL DEFAULT('0')," +
            "  titles varchar(200) DEFAULT(NULL)," +
            "  contents varchar(1000) DEFAULT(NULL)," +
            "  changeTime datetime DEFAULT(NULL)," +
            "  orderId int(11) NOT NULL DEFAULT('0')," +
            "  imgPath varchar(200) DEFAULT(NULL)," +
            "  imgUrl varchar(200) DEFAULT(NULL)," +
            "  createTime datetime DEFAULT(NULL)," +
            "  lType int(11) NOT NULL DEFAULT('0')," +
            "  style int(11) NOT NULL DEFAULT('0')," +
            "  endstate int(11) NOT NULL DEFAULT('1')," +
            "  nums varchar(50) NOT NULL DEFAULT('0')," +
            "  cpath varchar(200) DEFAULT(NULL)," +
            "  curl varchar(200) DEFAULT(NULL)," +
            "  shareUrl varchar(200) DEFAULT(NULL)," +
            "  sdesc varchar(100) DEFAULT(NULL)," +
            "  localIds varchar(50) NOT NULL DEFAULT('0')," +
            "  remark varchar(50) DEFAULT(NULL)," +
            "  remark1 varchar(50) DEFAULT(NULL)," +
            "  remark2 varchar(50) DEFAULT(NULL)," +
            "  remark3 varchar(200) DEFAULT(NULL)," +
            "  remark4 varchar(200) DEFAULT(NULL)," +
            "  remark5 varchar(50) DEFAULT(NULL)," +
            "  remark6 varchar(50) DEFAULT(NULL),updatestate integer(128) NOT NULL DEFAULT(0)" +
            ");";

    public static String NewTagTable_sql = "";
    public static String LocateSolarToLunar_sql = "";
    public static String CLRepeatTable_sql = "";
    public static String LocateAllNoticeTable_sql = "";

    /**
     * 修改所有的uid
     *
     * @param uid
     */
    public void updateUID(String uid) {

    }

    /**
     * 创建表
     */
    public void createTbale() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(FriendsListTableSQL);
        sqldb.execSQL(FriendDownAllScheduleBeanSQL);
        createTbaleFriendCommonReply();
    }

    /**
     * 创建新消息表
     */
    public void createCLCommentTable() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(CLCommentTableSQL);
    }

    /**
     * 创建清单版本的表
     */
    public void createCLInventoryModelTable() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_user_detail_list_title);
        //避免报错
        SQLiteDatabase sqldb1 = helper.getWritableDatabase();
        sqldb1.execSQL(tb_user_detail_list_class1);

        SQLiteDatabase sqldb2 = helper.getWritableDatabase();
        sqldb2.execSQL(tb_user_detail_list_type);

        SQLiteDatabase sqldb3 = helper.getWritableDatabase();
        sqldb3.execSQL(tb_newfriend);
    }

    /**
     * 6.0.8
     */
    public void CreateCalenderNote() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(calndernote);
    }

    /**
     * 6.3.3
     */
    public void Createtb_tb_timepreinstall_list_class1() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_timepreinstall_list_class1);
    }

    /**
     * 6.0.9
     */
    public void Createtb_user_detail_ly() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_user_detail_ly);
    }

    /**
     * 6.1.3
     */

    public void Create_tb_calendar_list_class1() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_calendar_list_class1);
    }

    /**
     * 6.2.5
     */

    public void Create_tb_function_my() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_function_my);
    }

    /**
     * 6.3.6
     */

    public void insert_tb_function_my() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String repType = "alter TABLE tb_function_my ADD repType int not null default 0";//1每天,2每周,3每月,4每年,5工作日6农历
        String repTypeParameter = "alter TABLE tb_function_my ADD repTypeParameter varchar not null default ''";//格式[12]
        String remark1 = "alter TABLE tb_function_my ADD remark1 varchar default '1'";//0轻应用 1常用语
        String remark2 = "alter TABLE tb_function_my ADD remark2 varchar default ''";//时间
        String remark3 = "alter TABLE tb_function_my ADD remark3 varchar default ''";//全天
        String remark4 = "alter TABLE tb_function_my ADD remark4 varchar default '1'";//0结束 1未结束
        try {
            if (!new DBHelper(this).checkColumnExists("tb_function_my", "repType")) {
                sqldb.execSQL(repType);
                sqldb.execSQL(repTypeParameter);
                sqldb.execSQL(remark1);
                sqldb.execSQL(remark2);
                sqldb.execSQL(remark3);
                sqldb.execSQL(remark4);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 6.2.0
     */

    public void Create_frends_task() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_user_frends_task);
        sqldb.execSQL(tb_user_frends_task_class1);
        String dataType = "alter TABLE CLRepeatTable ADD dataType varchar not null default '0'";//1 任务
        String dataId = "alter TABLE CLRepeatTable ADD dataId varchar not null default ''";
        String remark1 = "alter TABLE CLRepeatTable ADD remark1 varchar default ''";
        String remark2 = "alter TABLE CLRepeatTable ADD remark2 varchar default ''";
        String remark3 = "alter TABLE CLRepeatTable ADD remark3 varchar default ''";
        String remark4 = "alter TABLE CLRepeatTable ADD remark4 varchar default ''";
        String remark5 = "alter TABLE CLRepeatTable ADD remark5 varchar default ''";
        try {
            if (!new DBHelper(this).checkColumnExists("CLRepeatTable", "dataType")) {
                sqldb.execSQL(dataType);
                sqldb.execSQL(dataId);
                sqldb.execSQL(remark1);
                sqldb.execSQL(remark2);
                sqldb.execSQL(remark3);
                sqldb.execSQL(remark4);
                sqldb.execSQL(remark5);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 6.3.2
     */

    public void Create_Sch_key() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String remark6 = "alter TABLE ScheduleTable ADD schRemark6 varchar not null default ''";
        String remark7 = "alter TABLE ScheduleTable ADD schRemark7 varchar not null default ''";
        String remark8 = "alter TABLE ScheduleTable ADD schRemark8 varchar not null default ''";
        String remark9 = "alter TABLE ScheduleTable ADD schRemark9 varchar not null default ''";
        String remark10 = "alter TABLE ScheduleTable ADD schRemark10 varchar not null default ''";//文字颜色
        String remark11 = "alter TABLE ScheduleTable ADD schRemark11 varchar not null default ''";//文字背景颜色
        String remark12 = "alter TABLE ScheduleTable ADD schRemark12 varchar not null default ''";
        try {
            if (!new DBHelper(this).checkColumnExists("ScheduleTable", "schRemark6")) {
                sqldb.execSQL(remark6);
                sqldb.execSQL(remark7);
                sqldb.execSQL(remark8);
                sqldb.execSQL(remark9);
                sqldb.execSQL(remark10);
                sqldb.execSQL(remark11);
                sqldb.execSQL(remark12);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 创建表
     */
    public void createTbaleFriendCommonReply() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(FriendCommonReply);

        String friend = "insert into FriendCommonReply(message) values(?)";
        Object[] mValue = new Object[]{"已收到"};
        try {
            sqldb.execSQL(friend, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 版本618添加日程字段
     */
    public void add618ScheduleTableColumns() {
        String schpidend = "alter TABLE ScheduleTable ADD schpisEnd integer not null default 0";
        String schRemark1 = "alter TABLE ScheduleTable ADD schRemark1 varchar default '0'";
        String schRemark2 = "alter TABLE ScheduleTable ADD schRemark2 varchar default ''";
        String schRemark3 = "alter TABLE ScheduleTable ADD schRemark3 varchar default ''";
        String schRemark4 = "alter TABLE ScheduleTable ADD schRemark4 varchar default ''";
        String schRemark5 = "alter TABLE ScheduleTable ADD schRemark5 varchar default ''";
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        try {
            if (!new DBHelper(this).checkColumnExists("ScheduleTable", "schpisEnd")) {
                sqldb.execSQL(schpidend);
                sqldb.execSQL(schRemark1);
                sqldb.execSQL(schRemark2);
                sqldb.execSQL(schRemark3);
                sqldb.execSQL(schRemark4);
                sqldb.execSQL(schRemark5);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 重复推荐
     */
    public void createRepeatTuiJian() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        sqldb.execSQL(tb_timepreinstall_recommend_type);
        //避免报错
        SQLiteDatabase sqldb1 = helper.getWritableDatabase();
        sqldb1.execSQL(tb_timepreinstal_recommend_type_content);
    }


    //清所有表数据
    public void douleClear() {
        try {
            SQLiteDatabase sqldb = helper.getWritableDatabase();

            String ScheduleTable = "delete from ScheduleTable";

            sqldb.execSQL(ScheduleTable);

            String sql_fdas = "delete from FriendDownAllScheduleBean";

            sqldb.execSQL(sql_fdas);


            String sql_flt = "delete from FriendsListTable";

            sqldb.execSQL(sql_flt);
            String CLRepeatTable = "delete from CLRepeatTable";

            sqldb.execSQL(CLRepeatTable);

            String FriendCommonReply = "delete from FriendCommonReply";

            sqldb.execSQL(FriendCommonReply);

            DBHelper helper = new DBHelper(this);
            if (helper.tabIsExist("CLCommentTable")) {
                String CLCommentTable = "delete from CLCommentTable";
                sqldb.execSQL(CLCommentTable);
            }

            String sql_cl = "delete from CLCategoryTable";

            sqldb.execSQL(sql_cl);
            if (helper.tabIsExist("tb_user_detail_list_title")) {
                String CLCommentTable = "delete from tb_user_detail_list_title";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_user_detail_list_class1")) {
                String CLCommentTable = "delete from tb_user_detail_list_class1";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_user_detail_list_type")) {
                String CLCommentTable = "delete from tb_user_detail_list_type";
                sqldb.execSQL(CLCommentTable);
            }

            if (helper.tabIsExist("tb_timepreinstall_recommend_type")) {
                String CLCommentTable = "delete from tb_timepreinstall_recommend_type";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_timepreinstal_recommend_type_content")) {
                String CLCommentTable = "delete from tb_timepreinstal_recommend_type_content";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("NewFriendTable")) {
                String CLCommentTable = "delete from NewFriendTable";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("CalenderNote")) {
                String CLCommentTable = "delete from CalenderNote";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_user_detail_ly")) {
                String CLCommentTable = "delete from tb_user_detail_ly";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_calendar_list_class1")) {
                String CLCommentTable = "delete from tb_calendar_list_class1";
                sqldb.execSQL(CLCommentTable);
            }
//            if (helper.tabIsExist("tb_function_my")) {
//                String CLCommentTable = "delete from tb_function_my";
//                sqldb.execSQL(CLCommentTable);
//            }
            if (helper.tabIsExist("tb_user_frends_task")) {
                String CLCommentTable = "delete from tb_user_frends_task";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_user_frends_task_class1")) {
                String CLCommentTable = "delete from tb_user_frends_task_class1";
                sqldb.execSQL(CLCommentTable);
            }
            if (helper.tabIsExist("tb_timepreinstall_list_class1")) {
                String CLCommentTable = "delete from tb_timepreinstall_list_class1";
                sqldb.execSQL(CLCommentTable);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //清
    public void clearFriendDownAllScheduleBea() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql_fdas = "delete from FriendDownAllScheduleBean";

        sqldb.execSQL(sql_fdas);

    }

    //清
    public void clearFriendsListTable() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql_flt = "delete from FriendsListTable";

        sqldb.execSQL(sql_flt);
    }

    public void deleteFriends(String cpid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql_flt = "delete from FriendsListTable where cpid='" + cpid + "'";

        sqldb.execSQL(sql_flt);
    }

    //存储日程
    public void insertFriendSchedule(final FriendDownAllScheduleBean allScheduleBean) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateSql = "select * from FriendDownAllScheduleBean where id='" + allScheduleBean.id + "'";

        try {
            String id = "";
            Cursor cursor = sqldb.rawQuery(updateSql, null);
            while (cursor.moveToNext()) {
                id = cursor.getString(cursor.getColumnIndex(FriendBeanTable.id));
            }
            cursor.close();
            if (!id.equals("")) {
                updateFriendDownSchedule3(allScheduleBean);
            } else {
                String StrFriend = "insert into FriendDownAllScheduleBean(CAlarmsound,CAlarmsoundDesc,CLightAppId, COpenstate,"
                        + "CPostpone, CRecommendName, CTags,CType, CTypeDesc,"
                        + "CTypeSpare,atype, calendaId,cbeforTime, cdate, "
                        + "changTime,cisAlarm, cpId, cretetime,ctime, downNum,"
                        + "downstate,endNum,endState, id,imgPath, "
                        + "lyNum, message,parReamrk, pid, poststate,remark,"
                        + " remark1, remark2,remark3, repCalendaState,repCalendaTime,"
                        + " repColorType,repDisplayTime, repInStable,"
                        + "repIsPuase, repState,repType, repTypeParameter,"
                        + " repdatetwo,repinitialcreatedtime,replastcreatedtime, repnextcreatedtime,repstartdate, "
                        + "repstatetwo,schIsImportant,status, uid,webUrl) "
                        + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,"
                        + "?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                Object[] mValue = new Object[]{
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CAlarmsound),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CAlarmsoundDesc),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CLightAppId),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.COpenstate),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CPostpone),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CRecommendName),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CTags),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CType),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CTypeDesc),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.CTypeSpare),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.atype),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.calendaId),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.cbeforTime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.cdate),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.changTime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.cisAlarm),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.cpId),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.cretetime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.ctime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.downNum),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.downstate),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.endNum),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.endState),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.id),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.imgPath),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.lyNum),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.message),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.parReamrk),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.pid),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.poststate),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.remark),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.remark1),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.remark2),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.remark3),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repCalendaState),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repCalendaTime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repColorType),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repDisplayTime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repInStable),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repIsPuase),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repState),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repType),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repTypeParameter),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repdatetwo),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repinitialcreatedtime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.replastcreatedtime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repnextcreatedtime),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repstartdate),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.repstatetwo),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.schIsImportant),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.status),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.uid),
                        StringUtils.getIsStringEqulesNull(allScheduleBean.webUrl)};
                try {
                    sqldb.execSQL(StrFriend, mValue);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void insert_tb_function_my(final WBA_FindFunctionMy.ListBean listBean) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String StrFriend = "replace into tb_function_my(id,name,image, type,"
                + "url, androidDownLoadUrl, androidUrl,iosDownLoadUrl, iosUrl,"
                + "hotType,orderIndex,createTime,updateTime, urlType, "
                + "appType,repType,repTypeParameter,remark1,remark2,remark3,remark4) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{
                StringUtils.getIsIntEqulesNull(listBean.id),
                StringUtils.getIsStringEqulesNull(listBean.name),
                StringUtils.getIsStringEqulesNull(listBean.image),
                StringUtils.getIsIntEqulesNull(listBean.type),
                StringUtils.getIsStringEqulesNull(listBean.url),
                StringUtils.getIsStringEqulesNull(listBean.androidDownLoadUrl),
                StringUtils.getIsStringEqulesNull(listBean.androidUrl),
                StringUtils.getIsStringEqulesNull(listBean.iosDownLoadUrl),
                StringUtils.getIsStringEqulesNull(listBean.iosUrl),
                StringUtils.getIsIntEqulesNull(listBean.hotType),
                StringUtils.getIsIntEqulesNull(listBean.orderIndex),
                StringUtils.getIsStringEqulesNull(listBean.createTime),
                StringUtils.getIsStringEqulesNull(listBean.updateTime),
                StringUtils.getIsIntEqulesNull(listBean.urlType),
                StringUtils.getIsIntEqulesNull(listBean.appType),
                StringUtils.getIsIntEqulesNull(listBean.repType),
                StringUtils.getIsStringEqulesNull(listBean.repTypeParameter),
                StringUtils.getIsStringEqulesNull(listBean.remark1),
                StringUtils.getIsStringEqulesNull(listBean.remark2),
                StringUtils.getIsStringEqulesNull(listBean.remark3),
                StringUtils.getIsStringEqulesNull(listBean.remark4)};
        try {
            sqldb.execSQL(StrFriend, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public WBA_FindFunctionMy.ListBean get_tb_function_my(String id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        WBA_FindFunctionMy.ListBean noticeMap = null;
        if (id == null || id.isEmpty()) {
            return noticeMap;
        }
        String sql = "select * from tb_function_my where id = " + id;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new WBA_FindFunctionMy.ListBean();
                noticeMap.id = cursor.getInt(cursor.getColumnIndex("id"));
                noticeMap.name = cursor.getString(cursor.getColumnIndex("name"));
                noticeMap.image = cursor.getString(cursor.getColumnIndex("image"));
                noticeMap.type = cursor.getInt(cursor.getColumnIndex("type"));
                noticeMap.url = cursor.getString(cursor.getColumnIndex("url"));
                noticeMap.androidDownLoadUrl = cursor.getString(cursor.getColumnIndex("androidDownLoadUrl"));
                noticeMap.androidUrl = cursor.getString(cursor.getColumnIndex("androidUrl"));
                noticeMap.iosDownLoadUrl = cursor.getString(cursor.getColumnIndex("iosDownLoadUrl"));
                noticeMap.iosUrl = cursor.getString(cursor.getColumnIndex("iosUrl"));
                noticeMap.orderIndex = cursor.getInt(cursor.getColumnIndex("orderIndex"));
                noticeMap.hotType = cursor.getInt(cursor.getColumnIndex("hotType"));
                noticeMap.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                noticeMap.updateTime = cursor.getString(cursor.getColumnIndex("updateTime"));
                noticeMap.urlType = cursor.getInt(cursor.getColumnIndex("urlType"));
                noticeMap.appType = cursor.getInt(cursor.getColumnIndex("appType"));
                noticeMap.repType = cursor.getInt(cursor.getColumnIndex("repType"));
                noticeMap.repTypeParameter = cursor.getString(cursor.getColumnIndex("repTypeParameter"));
                noticeMap.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                noticeMap.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                noticeMap.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                noticeMap.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return noticeMap;
    }

    public List<WBA_FindFunctionMy.ListBean> getAll_tb_function_my(int... repType) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<WBA_FindFunctionMy.ListBean> list = new ArrayList<>();
        String where = "";
        int i = 0;
        for (Integer rep : repType) {
            where = " where " + (i > 1 ? " and " : " ") + " repType = " + rep;
            i++;
        }
        String sql = "select * from tb_function_my " + where + " order by repType desc, remark1 asc, orderIndex asc";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                WBA_FindFunctionMy.ListBean noticeMap = new WBA_FindFunctionMy.ListBean();
                noticeMap.id = cursor.getInt(cursor.getColumnIndex("id"));
                noticeMap.name = cursor.getString(cursor.getColumnIndex("name"));
                noticeMap.image = cursor.getString(cursor.getColumnIndex("image"));
                noticeMap.type = cursor.getInt(cursor.getColumnIndex("type"));
                noticeMap.url = cursor.getString(cursor.getColumnIndex("url"));
                noticeMap.androidDownLoadUrl = cursor.getString(cursor.getColumnIndex("androidDownLoadUrl"));
                noticeMap.androidUrl = cursor.getString(cursor.getColumnIndex("androidUrl"));
                noticeMap.iosDownLoadUrl = cursor.getString(cursor.getColumnIndex("iosDownLoadUrl"));
                noticeMap.iosUrl = cursor.getString(cursor.getColumnIndex("iosUrl"));
                noticeMap.orderIndex = cursor.getInt(cursor.getColumnIndex("orderIndex"));
                noticeMap.hotType = cursor.getInt(cursor.getColumnIndex("hotType"));
                noticeMap.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                noticeMap.updateTime = cursor.getString(cursor.getColumnIndex("updateTime"));
                noticeMap.urlType = cursor.getInt(cursor.getColumnIndex("urlType"));
                noticeMap.appType = cursor.getInt(cursor.getColumnIndex("appType"));
                noticeMap.repType = cursor.getInt(cursor.getColumnIndex("repType"));
                noticeMap.repTypeParameter = cursor.getString(cursor.getColumnIndex("repTypeParameter"));
                noticeMap.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                noticeMap.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                noticeMap.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                noticeMap.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                list.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    public List<WBA_FindFunctionMy.ListBean> getAllImage_tb_function_my() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<WBA_FindFunctionMy.ListBean> list = new ArrayList<>();
        String sql = "select * from tb_function_my where image != '' order by repType desc, remark1 asc, orderIndex asc";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                WBA_FindFunctionMy.ListBean noticeMap = new WBA_FindFunctionMy.ListBean();
                noticeMap.id = cursor.getInt(cursor.getColumnIndex("id"));
                noticeMap.name = cursor.getString(cursor.getColumnIndex("name"));
                noticeMap.image = cursor.getString(cursor.getColumnIndex("image"));
                noticeMap.type = cursor.getInt(cursor.getColumnIndex("type"));
                noticeMap.url = cursor.getString(cursor.getColumnIndex("url"));
                noticeMap.androidDownLoadUrl = cursor.getString(cursor.getColumnIndex("androidDownLoadUrl"));
                noticeMap.androidUrl = cursor.getString(cursor.getColumnIndex("androidUrl"));
                noticeMap.iosDownLoadUrl = cursor.getString(cursor.getColumnIndex("iosDownLoadUrl"));
                noticeMap.iosUrl = cursor.getString(cursor.getColumnIndex("iosUrl"));
                noticeMap.orderIndex = cursor.getInt(cursor.getColumnIndex("orderIndex"));
                noticeMap.hotType = cursor.getInt(cursor.getColumnIndex("hotType"));
                noticeMap.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                noticeMap.updateTime = cursor.getString(cursor.getColumnIndex("updateTime"));
                noticeMap.urlType = cursor.getInt(cursor.getColumnIndex("urlType"));
                noticeMap.appType = cursor.getInt(cursor.getColumnIndex("appType"));
                noticeMap.repType = cursor.getInt(cursor.getColumnIndex("repType"));
                noticeMap.repTypeParameter = cursor.getString(cursor.getColumnIndex("repTypeParameter"));
                noticeMap.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                noticeMap.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                noticeMap.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                noticeMap.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                list.add(noticeMap);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    //修改好友日程
    public void updateFriendDownSchedule3(FriendDownAllScheduleBean friendDownAllScheduleBean) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + FriendDownAllScheduleTable.FriendDownAllScheduleBean
                + " set "
                + FriendDownAllScheduleTable.CAlarmsound + "='"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CAlarmsound)
                + "', " + FriendDownAllScheduleTable.CAlarmsoundDesc + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CAlarmsoundDesc)
                + "', " + FriendDownAllScheduleTable.CLightAppId + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CLightAppId)
                + "', " + FriendDownAllScheduleTable.COpenstate + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.COpenstate)
                + "', " + FriendDownAllScheduleTable.CPostpone + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CPostpone)
                + "', " + FriendDownAllScheduleTable.CRecommendName + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CRecommendName)
                + "', " + FriendDownAllScheduleTable.CTags + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CTags)
                + "', " + FriendDownAllScheduleTable.CType + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CType)
                + "', " + FriendDownAllScheduleTable.CTypeDesc + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CTypeDesc)
                + "', " + FriendDownAllScheduleTable.CTypeSpare + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CTypeSpare)
                + "', " + FriendDownAllScheduleTable.atype + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.atype)
                + "', " + FriendDownAllScheduleTable.calendaId + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.calendaId)
                + "', " + FriendDownAllScheduleTable.cbeforTime + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cbeforTime)
                + "', " + FriendDownAllScheduleTable.cdate + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cdate)
                + "', " + FriendDownAllScheduleTable.changTime + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.changTime)
                + "', " + FriendDownAllScheduleTable.cisAlarm + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cisAlarm)
                + "', " + FriendDownAllScheduleTable.cpId + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cpId)
                + "', " + FriendDownAllScheduleTable.cretetime + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cretetime)
                + "', " + FriendDownAllScheduleTable.ctime + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.ctime)
                + "', " + FriendDownAllScheduleTable.downNum + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.downNum)
                + "', " + FriendDownAllScheduleTable.downstate + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.downstate)
                + "', " + FriendDownAllScheduleTable.endNum + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.endNum)
                + "', " + FriendDownAllScheduleTable.endState + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.endState)
                + "', " + FriendDownAllScheduleTable.imgPath + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.imgPath)
                + "', " + FriendDownAllScheduleTable.lyNum + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.lyNum)
                + "', " + FriendDownAllScheduleTable.message + " = '"
                + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.message)
                + "', " + FriendDownAllScheduleTable.parReamrk + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.parReamrk)
                + "', " + FriendDownAllScheduleTable.pid + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.pid)
                + "', " + FriendDownAllScheduleTable.poststate + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.poststate)
                + "', " + FriendDownAllScheduleTable.remark + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.remark)
                + "', " + FriendDownAllScheduleTable.remark1 + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.remark1)
                + "', " + FriendDownAllScheduleTable.remark2 + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.remark2)
                + "', " + FriendDownAllScheduleTable.remark3 + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.remark3)
                + "', " + FriendDownAllScheduleTable.repCalendaState + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repCalendaState)
                + "', " + FriendDownAllScheduleTable.repCalendaTime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repCalendaTime)
                + "', " + FriendDownAllScheduleTable.repColorType + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repColorType)
                + "', " + FriendDownAllScheduleTable.repDisplayTime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repDisplayTime)
                + "', " + FriendDownAllScheduleTable.repInStable + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repInStable)
                + "', " + FriendDownAllScheduleTable.repIsPuase + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repIsPuase)
                + "', " + FriendDownAllScheduleTable.repState + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repState)
                + "', " + FriendDownAllScheduleTable.repType + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repType)
                + "', " + FriendDownAllScheduleTable.repTypeParameter + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repTypeParameter)
                + "', " + FriendDownAllScheduleTable.repdatetwo + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repdatetwo)
                + "', " + FriendDownAllScheduleTable.repinitialcreatedtime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repinitialcreatedtime)
                + "', " + FriendDownAllScheduleTable.replastcreatedtime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.replastcreatedtime)
                + "', " + FriendDownAllScheduleTable.repnextcreatedtime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repnextcreatedtime)
                + "', " + FriendDownAllScheduleTable.repstartdate + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repstartdate)
                + "', " + FriendDownAllScheduleTable.repstatetwo + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repstatetwo)
                + "', " + FriendDownAllScheduleTable.schIsImportant + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.schIsImportant)
                + "', " + FriendDownAllScheduleTable.webUrl + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.webUrl)
                + "', " + FriendDownAllScheduleTable.status + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.status)
                + "', " + FriendDownAllScheduleTable.uid + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.uid)
                + "' where " + FriendDownAllScheduleTable.id + " = " + friendDownAllScheduleBean.id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询全部的常用回复
     *
     * @return
     */
    public ArrayList<CommonReplyBean> queryFriendCommonReply() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from FriendCommonReply";

        ArrayList<CommonReplyBean> list = new ArrayList<>();

        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                CommonReplyBean commonReplyBean = new CommonReplyBean();
                commonReplyBean.setMessage(cursor.getString(cursor.getColumnIndex("message")));
                commonReplyBean.setId(cursor.getInt(cursor.getColumnIndex("id")));
                list.add(commonReplyBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }


    /**
     * 删除常用回复
     *
     * @param id
     */
    public void deleteFriendCommonReply(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from FriendCommonReply where id=" + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 修改常用回复
     *
     * @param id
     * @param message
     */
    public void updateFriendCommonReply(int id, String message) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update FriendCommonReply set message=" + message
                + " where id=" + id + "";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询消息是否存在
     *
     * @param message
     * @return
     */
    public Boolean checkMessage(String message) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from FriendCommonReply where message=" + message;
        Boolean tag = false;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                if (cursor.getCount() > 0) {
                    tag = true;
                } else {
                    tag = false;
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tag;
    }

    /**
     * 插入回复
     *
     * @param message
     */
    public void insertFriendCommonReply(String message) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String friend = "insert into FriendCommonReply(message) values(?)";
        Object[] mValue = new Object[]{message};
        try {
            sqldb.execSQL(friend, mValue);
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    //查询好友日程
    public ArrayList<FriendDownAllScheduleBean> queryFriendSchedule(String uid) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<FriendDownAllScheduleBean> friendDownAllScheduleBeanArrayList = new ArrayList<>();

        String sql = "select * from " + FriendDownAllScheduleTable.FriendDownAllScheduleBean
                + " where " + FriendDownAllScheduleTable.id + "=" + uid + "";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                FriendDownAllScheduleBean friendDownAllScheduleBean = new FriendDownAllScheduleBean();
                friendDownAllScheduleBean.CAlarmsound = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CAlarmsound));
                friendDownAllScheduleBean.CAlarmsoundDesc = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CAlarmsoundDesc));
                friendDownAllScheduleBean.CLightAppId = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CLightAppId));
                friendDownAllScheduleBean.COpenstate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.COpenstate));
                friendDownAllScheduleBean.CPostpone = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CPostpone));
                friendDownAllScheduleBean.CRecommendName = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CRecommendName));
                friendDownAllScheduleBean.CTags = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CTags));
                friendDownAllScheduleBean.CType = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CType));
                friendDownAllScheduleBean.CTypeDesc = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CTypeDesc));
                friendDownAllScheduleBean.CTypeSpare = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CTypeSpare));
                friendDownAllScheduleBean.atype = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.atype));
                friendDownAllScheduleBean.calendaId = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.calendaId));
                friendDownAllScheduleBean.cbeforTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cbeforTime));
                friendDownAllScheduleBean.cdate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cdate));
                friendDownAllScheduleBean.changTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.changTime));
                friendDownAllScheduleBean.cisAlarm = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cisAlarm));
                friendDownAllScheduleBean.cpId = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cpId));
                friendDownAllScheduleBean.cretetime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cretetime));
                friendDownAllScheduleBean.ctime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.ctime));
                friendDownAllScheduleBean.downNum = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.downNum));
                friendDownAllScheduleBean.downstate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.downstate));
                friendDownAllScheduleBean.endNum = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.endNum));
                friendDownAllScheduleBean.endState = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.endState));
                friendDownAllScheduleBean.id = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.id));
                friendDownAllScheduleBean.imgPath = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.imgPath));
                friendDownAllScheduleBean.lyNum = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.lyNum));
                friendDownAllScheduleBean.message = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.message));
                friendDownAllScheduleBean.parReamrk = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.parReamrk));
                friendDownAllScheduleBean.pid = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.pid));
                friendDownAllScheduleBean.poststate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.poststate));
                friendDownAllScheduleBean.remark = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark));
                friendDownAllScheduleBean.remark1 = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark1));
                friendDownAllScheduleBean.remark2 = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark2));
                friendDownAllScheduleBean.remark3 = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark3));
                friendDownAllScheduleBean.repCalendaState = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repCalendaState));
                friendDownAllScheduleBean.repCalendaTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repCalendaTime));
                friendDownAllScheduleBean.repColorType = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repColorType));
                friendDownAllScheduleBean.repDisplayTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repDisplayTime));
                friendDownAllScheduleBean.repInStable = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repInStable));
                friendDownAllScheduleBean.repIsPuase = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repIsPuase));
                friendDownAllScheduleBean.repState = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repType));
                friendDownAllScheduleBean.repType = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repType));
                friendDownAllScheduleBean.repTypeParameter = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repTypeParameter));
                friendDownAllScheduleBean.repdatetwo = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repdatetwo));
                friendDownAllScheduleBean.repinitialcreatedtime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repinitialcreatedtime));
                friendDownAllScheduleBean.replastcreatedtime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.replastcreatedtime));
                friendDownAllScheduleBean.repnextcreatedtime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repnextcreatedtime));
                friendDownAllScheduleBean.repstartdate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repstartdate));
                friendDownAllScheduleBean.repstatetwo = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repstartdate));
                friendDownAllScheduleBean.schIsImportant = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.schIsImportant));
                friendDownAllScheduleBean.status = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.status));
                friendDownAllScheduleBean.uid = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.uid));
                friendDownAllScheduleBean.webUrl = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.webUrl));
                friendDownAllScheduleBeanArrayList.add(friendDownAllScheduleBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return friendDownAllScheduleBeanArrayList;
    }


    //插入好友信息
    public void insertFriendsList(FriendBean friendBean) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        if (queryFriends(friendBean.cpId).size() > 0) {
            String sql = "update " + FriendBeanTable.FriendTable
                    + " set "
                    + FriendBeanTable.uid + "='" + friendBean.uid
                    + "'," + FriendBeanTable.id + "='" + friendBean.id
                    + "'," + FriendBeanTable.uPersontag + "='" + friendBean.uPersontag
                    + "'," + FriendBeanTable.uToCode + "='" + friendBean.uToCode
                    + "'," + FriendBeanTable.remark + "='" + friendBean.remark
                    + "'," + FriendBeanTable.uPortrait + "='" + friendBean.uPortrait
                    + "'," + FriendBeanTable.dateUpdate + "='" + friendBean.dateUpdate
                    + "'," + FriendBeanTable.uBackgroundImage + "='" + friendBean.uBackgroundImage
                    + "'," + FriendBeanTable.uNickName + "='" + friendBean.uNickName
                    + "'," + FriendBeanTable.type + "='" + friendBean.type
                    + "' where " + FriendBeanTable.cpId + "=" + friendBean.cpId;
            try {
                sqldb.execSQL(sql);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            String friend = "insert into FriendsListTable("
                    + "uid, id, cpId,uPersontag, uToCode,"
                    + "remark,uPortrait, dateUpdate,uNickName, type,uBackgroundImage)"
                    + "values(?,?,?,?,?,?,?,?,?,?,?)";
            Object[] mValue = new Object[]{
                    StringUtils.getIsStringEqulesNull(friendBean.uid),
                    StringUtils.getIsStringEqulesNull(friendBean.id),
                    StringUtils.getIsStringEqulesNull(friendBean.cpId),
                    StringUtils.getIsStringEqulesNull(friendBean.uPersontag),
                    StringUtils.getIsStringEqulesNull(friendBean.uToCode),
                    StringUtils.getIsStringEqulesNull(friendBean.remark),
                    StringUtils.getIsStringEqulesNull(friendBean.uPortrait),
                    StringUtils.getIsStringEqulesNull(friendBean.dateUpdate),
                    StringUtils.getIsStringEqulesNull(friendBean.uNickName),
                    StringUtils.getIsStringEqulesNull(friendBean.type),
                    StringUtils.getIsStringEqulesNull(friendBean.uBackgroundImage)};
            try {
                sqldb.execSQL(friend, mValue);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }


    /**
     * 查询好友
     *
     * @param cpid
     * @return
     */
    public ArrayList<FriendBean> queryFriends(String cpid) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<FriendBean> list = new ArrayList<>();

        String sql = "select * from " + FriendBeanTable.FriendTable
                + " where " + FriendBeanTable.cpId + "=" + cpid + "";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                FriendBean friendBean = new FriendBean();
                friendBean.uid = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uid));
                friendBean.cpId = cursor.getString(cursor.getColumnIndex(FriendBeanTable.cpId));
                friendBean.id = cursor.getString(cursor.getColumnIndex(FriendBeanTable.id));
                friendBean.uToCode = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uToCode));
                friendBean.remark = cursor.getString(cursor.getColumnIndex(FriendBeanTable.remark));
                friendBean.uPortrait = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uPortrait));
                friendBean.dateUpdate = cursor.getString(cursor.getColumnIndex(FriendBeanTable.dateUpdate));
                friendBean.uNickName = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uNickName));
                friendBean.uPersontag = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uPersontag));
                friendBean.type = cursor.getString(cursor.getColumnIndex(FriendBeanTable.type));
                friendBean.uBackgroundImage = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uBackgroundImage));
                list.add(friendBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }


    //全部好友日程
    public ArrayList<FriendDownAllScheduleBean> getAllFriendSchedule() {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<FriendDownAllScheduleBean> friendDownAllScheduleBeanArrayList = new ArrayList<>();

        String sql = "select * from " + FriendDownAllScheduleTable.FriendDownAllScheduleBean;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                FriendDownAllScheduleBean friendDownAllScheduleBean = new FriendDownAllScheduleBean();
                friendDownAllScheduleBean.CAlarmsound = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CAlarmsound));
                friendDownAllScheduleBean.CAlarmsoundDesc = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CAlarmsoundDesc));
                friendDownAllScheduleBean.CLightAppId = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CLightAppId));
                friendDownAllScheduleBean.COpenstate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.COpenstate));
                friendDownAllScheduleBean.CPostpone = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CPostpone));
                friendDownAllScheduleBean.CRecommendName = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CRecommendName));
                friendDownAllScheduleBean.CTags = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CTags));
                friendDownAllScheduleBean.CType = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CType));
                friendDownAllScheduleBean.CTypeDesc = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CTypeDesc));
                friendDownAllScheduleBean.CTypeSpare = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.CTypeSpare));
                friendDownAllScheduleBean.atype = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.atype));
                friendDownAllScheduleBean.calendaId = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.calendaId));
                friendDownAllScheduleBean.cbeforTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cbeforTime));
                friendDownAllScheduleBean.cdate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cdate));
                friendDownAllScheduleBean.changTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.changTime));
                friendDownAllScheduleBean.cisAlarm = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cisAlarm));
                friendDownAllScheduleBean.cpId = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cpId));
                friendDownAllScheduleBean.cretetime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.cretetime));
                friendDownAllScheduleBean.ctime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.ctime));
                friendDownAllScheduleBean.downNum = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.downNum));
                friendDownAllScheduleBean.downstate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.downstate));
                friendDownAllScheduleBean.endNum = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.endNum));
                friendDownAllScheduleBean.endState = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.endState));
                friendDownAllScheduleBean.id = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.id));
                friendDownAllScheduleBean.imgPath = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.imgPath));
                friendDownAllScheduleBean.lyNum = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.lyNum));
                friendDownAllScheduleBean.message = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.message));
                friendDownAllScheduleBean.parReamrk = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.parReamrk));
                friendDownAllScheduleBean.pid = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.pid));
                friendDownAllScheduleBean.poststate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.poststate));
                friendDownAllScheduleBean.remark = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark));
                friendDownAllScheduleBean.remark1 = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark1));
                friendDownAllScheduleBean.remark2 = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark2));
                friendDownAllScheduleBean.remark3 = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.remark3));
                friendDownAllScheduleBean.repCalendaState = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repCalendaState));
                friendDownAllScheduleBean.repCalendaTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repCalendaTime));
                friendDownAllScheduleBean.repColorType = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repColorType));
                friendDownAllScheduleBean.repDisplayTime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repDisplayTime));
                friendDownAllScheduleBean.repInStable = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repInStable));
                friendDownAllScheduleBean.repIsPuase = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repIsPuase));
                friendDownAllScheduleBean.repState = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repType));
                friendDownAllScheduleBean.repType = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repType));
                friendDownAllScheduleBean.repTypeParameter = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repTypeParameter));
                friendDownAllScheduleBean.repdatetwo = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repdatetwo));
                friendDownAllScheduleBean.repinitialcreatedtime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repinitialcreatedtime));
                friendDownAllScheduleBean.replastcreatedtime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.replastcreatedtime));
                friendDownAllScheduleBean.repnextcreatedtime = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repnextcreatedtime));
                friendDownAllScheduleBean.repstartdate = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repstartdate));
                friendDownAllScheduleBean.repstatetwo = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.repstartdate));
                friendDownAllScheduleBean.schIsImportant = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.schIsImportant));
                friendDownAllScheduleBean.status = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.status));
                friendDownAllScheduleBean.uid = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.uid));
                friendDownAllScheduleBean.webUrl = cursor.getString(cursor.getColumnIndex(FriendDownAllScheduleTable.webUrl));
                friendDownAllScheduleBeanArrayList.add(friendDownAllScheduleBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return friendDownAllScheduleBeanArrayList;
    }

    //好友信息
    public ArrayList<FriendBean> backFriendsList(String uid) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<FriendBean> friendDownAllScheduleBeanArrayList = new ArrayList<>();

        String sql = "select * from " + FriendBeanTable.FriendTable + " where uid=" + uid;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                FriendBean friendBean = new FriendBean();
                /***
                 * "uid": 52432,
                 * "id": 767,
                 * "cpId": 260975,
                 * "uPersontag": "加油加油！",
                 * "uToCode": "iPhone",
                 * "remark": null,
                 * "uPortrait": "20150925136/638645.jpg",
                 * "dateUpdate": "2016-09-05T10:42:55",
                 * "uNickName": "韩雪h",
                 * "type": 0,
                 * "uBackgroundImage": "20160820/933727.png"
                 */

                friendBean.uid = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uid));
                friendBean.id = cursor.getString(cursor.getColumnIndex(FriendBeanTable.id));
                friendBean.cpId = cursor.getString(cursor.getColumnIndex(FriendBeanTable.cpId));
                friendBean.uPersontag = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uPersontag));
                friendBean.uToCode = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uToCode));
                friendBean.remark = cursor.getString(cursor.getColumnIndex(FriendBeanTable.remark));
                friendBean.uPortrait = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uPortrait));
                friendBean.dateUpdate = cursor.getString(cursor.getColumnIndex(FriendBeanTable.dateUpdate));
                friendBean.uNickName = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uNickName));
                friendBean.type = cursor.getString(cursor.getColumnIndex(FriendBeanTable.type));
                friendBean.uBackgroundImage = cursor.getString(cursor.getColumnIndex(FriendBeanTable.uBackgroundImage));
                friendDownAllScheduleBeanArrayList.add(friendBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return friendDownAllScheduleBeanArrayList;
    }

    //删除好友下行日程
    public void deleteFriendSchedule(String id) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from " + FriendDownAllScheduleTable.FriendDownAllScheduleBean
                + " where " + FriendDownAllScheduleTable.id + "=" + id + "";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //删除好友
    public void deleteFriend(String cpId) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from " + FriendBeanTable.FriendTable
                + " where " + FriendDownAllScheduleTable.cpId + "=" + cpId + "";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //修改好友日程状态
    public void updateFriendScheduleType(String id, String poststate) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update " + FriendDownAllScheduleTable.FriendDownAllScheduleBean + " set " + FriendDownAllScheduleTable.poststate + "=" + poststate
                + " where " + FriendDownAllScheduleTable.id + "=" + id + "";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //修改好友日程
    public void updateFriendDownSchedule2(FriendDownAllScheduleBean friendDownAllScheduleBean) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + FriendDownAllScheduleTable.FriendDownAllScheduleBean
                + " set "
                + FriendDownAllScheduleTable.CAlarmsound + " = '" + friendDownAllScheduleBean.CAlarmsound
                + "', " + FriendDownAllScheduleTable.CAlarmsoundDesc + " = '" + friendDownAllScheduleBean.CAlarmsoundDesc
                + "', " + FriendDownAllScheduleTable.message + " = '" + friendDownAllScheduleBean.message
                + "', " + FriendDownAllScheduleTable.atype + " = '" + friendDownAllScheduleBean.atype
                + "', " + FriendDownAllScheduleTable.cbeforTime + " = '" + friendDownAllScheduleBean.cbeforTime
                + "', " + FriendDownAllScheduleTable.cdate + " = '" + friendDownAllScheduleBean.cdate
                + "', " + FriendDownAllScheduleTable.cisAlarm + " = '" + friendDownAllScheduleBean.cisAlarm
                + "', " + FriendDownAllScheduleTable.ctime + " = '" + friendDownAllScheduleBean.ctime
                + "', " + FriendDownAllScheduleTable.repDisplayTime + " = '" + friendDownAllScheduleBean.repDisplayTime
                + "', " + FriendDownAllScheduleTable.webUrl + " = '" + friendDownAllScheduleBean.webUrl
                + "'  where " + FriendDownAllScheduleTable.id + "=" + friendDownAllScheduleBean.id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //修改好友日程
    public void updateFriendDownSchedule(FrendBean friendDownAllScheduleBean) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update " + FriendDownAllScheduleTable.FriendDownAllScheduleBean
                + " set "
                + FriendDownAllScheduleTable.CAlarmsound + "= '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CAlarmsound)
                + "', " + FriendDownAllScheduleTable.CAlarmsoundDesc + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CAlarmsoundDesc)
                + "', " + FriendDownAllScheduleTable.message + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.message)
                + "', " + FriendDownAllScheduleTable.atype + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.atype)
                + "', " + FriendDownAllScheduleTable.cbeforTime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cbeforTime)
                + "', " + FriendDownAllScheduleTable.cdate + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cdate)
                + "', " + FriendDownAllScheduleTable.cisAlarm + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.cisAlarm)
                + "', " + FriendDownAllScheduleTable.ctime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.ctime)
                + "', " + FriendDownAllScheduleTable.repDisplayTime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.repDisplayTime)
                + "', " + FriendDownAllScheduleTable.webUrl + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.webUrl)
                + "', " + FriendDownAllScheduleTable.poststate + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.poststate)
                + "', " + FriendDownAllScheduleTable.downNum + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.downNum)
                + "', " + FriendDownAllScheduleTable.endNum + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.endNum)
                + "', " + FriendDownAllScheduleTable.changTime + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.changTime)
                + "', " + FriendDownAllScheduleTable.downstate + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.downstate)
                + "', " + FriendDownAllScheduleTable.endState + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.endState)
                + "', " + FriendDownAllScheduleTable.CTypeDesc + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CTypeDesc)
                + "', " + FriendDownAllScheduleTable.CTypeSpare + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CTypeSpare)
                + "', " + FriendDownAllScheduleTable.CAlarmsound + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.CAlarmsound)
                + "', " + FriendDownAllScheduleTable.COpenstate + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.COpenstate)
                + "', " + FriendDownAllScheduleTable.remark + " = '" + StringUtils.getIsStringEqulesNull(friendDownAllScheduleBean.remark)
                + "'  where " + FriendDownAllScheduleTable.id + "=" + friendDownAllScheduleBean.id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    //插入全部日程留言
    public void insertAllCalenderLy(FrendLyBean frendLyBean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();

        String sql = "insert into FrendLyTable(uid,id,uToCode,remark,uPortrait,changeTime,mess,uNickName,cId,uBackgroundImage,cType) values(?,?,?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsStringEqulesNull(frendLyBean.uid),
                StringUtils.getIsStringEqulesNull(frendLyBean.id),
                StringUtils.getIsStringEqulesNull(frendLyBean.uToCode),
                StringUtils.getIsStringEqulesNull(frendLyBean.remark),
                StringUtils.getIsStringEqulesNull(frendLyBean.uPortrait),
                StringUtils.getIsStringEqulesNull(frendLyBean.changeTime),
                StringUtils.getIsStringEqulesNull(frendLyBean.mess),
                StringUtils.getIsStringEqulesNull(frendLyBean.uNickName),
                StringUtils.getIsStringEqulesNull(frendLyBean.cId),
                StringUtils.getIsStringEqulesNull(frendLyBean.uBackgroundImage),
                StringUtils.getIsStringEqulesNull(frendLyBean.cType),};

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //查询日程下留言
    public ArrayList<FrendLyBean> getFrendLy(String cid) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();

        ArrayList<FrendLyBean> frendLyBeanArrayList = new ArrayList<>();
        ArrayList<FrendLyBean> frendLyBeanArray = new ArrayList<>();

        String sql = "select * from FrendLyTable where cId=" + cid;

        Cursor cursor = sqLiteDatabase.rawQuery(sql, null);
        try {
            while (cursor.moveToNext()) {
                FrendLyBean frendLyBean = new FrendLyBean();
                frendLyBean.uid = cursor.getString(cursor.getColumnIndex("uid"));
                frendLyBean.id = cursor.getString(cursor.getColumnIndex("id"));
                frendLyBean.uToCode = cursor.getString(cursor.getColumnIndex("uToCode"));
                frendLyBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                frendLyBean.uPortrait = cursor.getString(cursor.getColumnIndex("uPortrait"));
                frendLyBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                frendLyBean.mess = cursor.getString(cursor.getColumnIndex("mess"));
                frendLyBean.uNickName = cursor.getString(cursor.getColumnIndex("uNickName"));
                frendLyBean.cId = cursor.getString(cursor.getColumnIndex("cId"));
                frendLyBean.uBackgroundImage = cursor.getString(cursor.getColumnIndex("uBackgroundImage"));
                frendLyBean.cType = cursor.getString(cursor.getColumnIndex("cType"));
                frendLyBeanArrayList.add(frendLyBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (frendLyBeanArrayList.size() > 0 && frendLyBeanArrayList != null) {
            for (int i = frendLyBeanArrayList.size() - 1; i >= 0; i--) {
                frendLyBeanArray.add(frendLyBeanArrayList.get(i));
            }
        }

        frendLyBeanArrayList.clear();
        return frendLyBeanArray;
    }

    /**
     * 根据新消息内的id来获取该id日程信息
     */
    public List<Map<String, String>> getNewCan(String schId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
        Map<String, String> noticeMap = null;

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.DAY_OF_MONTH,
                calendar.get(Calendar.DAY_OF_MONTH) - 1);

        String today = DateUtil.formatDate(calendar.getTime());

        String sql = "select * from " + ScheduleTable.ScheduleTable + " where "
                + ScheduleTable.schRead + " = " + 1 + " and "
                + ScheduleTable.schIsEnd + " = " + 0 + " and "
                + ScheduleTable.schUpdateState + " != " + 3 + " and "
                + ScheduleTable.schDate + " >= '" + today
                + "' and schID = " + schId + " and schRemark3 is not '1' and schColorType < 999999 order by schDate desc,schDisplayTime asc,schTime asc";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                noticeMap = new HashMap<String, String>();
                noticeMap.put(ScheduleTable.schID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schID)));
                noticeMap.put(ScheduleTable.schContent, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schContent)));
                noticeMap.put(ScheduleTable.schDate, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schDate)));
                noticeMap.put(ScheduleTable.schTime, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTime)));
                noticeMap.put(ScheduleTable.schIsAlarm, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsAlarm)));
                noticeMap.put(ScheduleTable.schBeforeTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schBeforeTime)));
                noticeMap.put(ScheduleTable.schDisplayTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schDisplayTime)));
                noticeMap.put(ScheduleTable.schIsPostpone, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsPostpone)));
                noticeMap.put(ScheduleTable.schIsImportant, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schIsImportant)));
                noticeMap.put(ScheduleTable.schColorType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schColorType)));
                noticeMap.put(ScheduleTable.schIsEnd, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schIsEnd)));
                noticeMap.put(ScheduleTable.schCreateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schCreateTime)));
                noticeMap.put(ScheduleTable.schTags, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schTags)));
                noticeMap.put(ScheduleTable.schSourceType, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceType)));
                noticeMap.put(ScheduleTable.schSourceDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schSourceDesc)));
                noticeMap
                        .put(ScheduleTable.schSourceDescSpare,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schSourceDescSpare)));
                noticeMap.put(ScheduleTable.schRepeatID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatID)));
                noticeMap.put(ScheduleTable.schRepeatDate, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatDate)));
                noticeMap.put(ScheduleTable.schUpdateTime, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateTime)));
                noticeMap.put(ScheduleTable.schUpdateState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schUpdateState)));
                noticeMap.put(ScheduleTable.schOpenState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schOpenState)));
                noticeMap.put(ScheduleTable.schRepeatLink, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRepeatLink)));
                noticeMap.put(ScheduleTable.schRingDesc, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingDesc)));
                noticeMap.put(ScheduleTable.schRingCode, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schRingCode)));
                noticeMap
                        .put(ScheduleTable.schcRecommendName,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendName)));
                noticeMap.put(ScheduleTable.schRead, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schRead)));
                noticeMap.put(ScheduleTable.schAID, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAID)));
                noticeMap.put(ScheduleTable.schAType, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schAType)));
                noticeMap.put(ScheduleTable.schWebURL, cursor.getString(cursor
                        .getColumnIndex(ScheduleTable.schWebURL)));
                noticeMap.put(ScheduleTable.schImagePath, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schImagePath)));
                noticeMap.put(ScheduleTable.schFocusState, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFocusState)));
                noticeMap.put(ScheduleTable.schFriendID, cursor
                        .getString(cursor
                                .getColumnIndex(ScheduleTable.schFriendID)));
                noticeMap
                        .put(ScheduleTable.schcRecommendId,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schcRecommendId)));
                noticeMap
                        .put(ScheduleTable.schpisEnd,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schpisEnd)));
                noticeMap
                        .put(ScheduleTable.schRemark1,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark1)));
                noticeMap
                        .put(ScheduleTable.schRemark2,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark2)));
                noticeMap
                        .put(ScheduleTable.schRemark3,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark3)));
                noticeMap
                        .put(ScheduleTable.schRemark4,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark4)));
                noticeMap
                        .put(ScheduleTable.schRemark5,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark5)));
                noticeMap
                        .put(ScheduleTable.schRemark6,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark6)));
                noticeMap
                        .put(ScheduleTable.schRemark7,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark7)));
                noticeMap
                        .put(ScheduleTable.schRemark10,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark10)));
                noticeMap
                        .put(ScheduleTable.schRemark11,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark11)));
                noticeMap
                        .put(ScheduleTable.schRemark12,
                                cursor.getString(cursor
                                        .getColumnIndex(ScheduleTable.schRemark12)));
                dataList.add(noticeMap);

            }

            cursor.close();

        } catch (Exception e) {
            e.printStackTrace();
        }

        for (int i = 0; i < dataList.size(); i++) {
            Map<String, String> m1 = dataList.get(i);
            for (int j = i + 1; j < dataList.size(); j++) {
                Map<String, String> m2 = dataList.get(j);
                if ((m1.get(ScheduleTable.schSourceType).equals("3") && m2.get(ScheduleTable.schSourceType).equals("3")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("4") && m2.get(ScheduleTable.schSourceType).equals("4")) ||
                        (m1.get(ScheduleTable.schSourceType).equals("5") && m2.get(ScheduleTable.schSourceType).equals("5"))) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc))) {
                        dataList.remove(j);
                        continue;
                    }
                }

                if (m1.get(ScheduleTable.schSourceType).equals("2") && m2.get(ScheduleTable.schSourceType).equals("2")) {
                    if (m2.get(ScheduleTable.schSourceDesc).isEmpty()) {
                        break;
                    }
                    if (m1.get(ScheduleTable.schSourceDesc).equals(m2.get(ScheduleTable.schSourceDesc)) && !m1.get(ScheduleTable.schcRecommendName).isEmpty()) {
                        dataList.remove(j - 1);
                        continue;
                    }
                }
            }
        }
        return dataList;
    }

    //删除新消息
    public void deleteNewInformationLy(int cmtMessageID) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from CLCommentTable where cmtMessageID = " + cmtMessageID + "";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public ArrayList<UserNewLy.ListBean> getNewInformationLy(String calendarId, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<UserNewLy.ListBean> listBeanArrayList = new ArrayList<>();
        String sql;
        if (calendarId.equals("")) {
            sql = "select * from CLCommentTable where cmtOperateTime <= cmtCreateTime and cmtIsNew = 0 and cmtUserID !=" + uid + " order by  cmtCreateTime desc , cmtSchID desc";
        } else {
            sql = "select * from CLCommentTable where cmtSchID=" + calendarId + " and cmtIsNew = 0 and cmtOperateTime <= cmtCreateTime and cmtUserID !=" + uid + " order by  cmtCreateTime desc , cmtSchID desc";
        }
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                UserNewLy.ListBean listBean = new UserNewLy.ListBean();
                listBean.uid = cursor.getString(cursor.getColumnIndex("cmtUserID"));
                listBean.opTime = cursor.getString(cursor.getColumnIndex("cmtOperateTime"));
                listBean.U_BACKGROUND_IMAGE = cursor.getString(cursor.getColumnIndex("cmtBackImage"));
                listBean.calendarId = cursor.getString(cursor.getColumnIndex("cmtSchID"));
                listBean.remark = cursor.getString(cursor.getColumnIndex("cmtSchContent"));
                listBean.changeTime = cursor.getString(cursor.getColumnIndex("cmtCreateTime"));
                listBean.mess = cursor.getString(cursor.getColumnIndex("cmtContent"));
                listBean.remark1 = cursor.getString(cursor.getColumnIndex("cmtSendName"));
                listBean.cType = cursor.getInt(cursor.getColumnIndex("cmtType"));
                listBean.remark2 = cursor.getString(cursor.getColumnIndex("cmtRemark2"));
                listBean.id = cursor.getInt(cursor.getColumnIndex("cmtMessageID"));
                listBean.schId = cursor.getString(cursor.getColumnIndex("cmtRemark"));
                listBean.U_NICK_NAME = cursor.getString(cursor.getColumnIndex("cmtNickName"));
                listBean.U_PORTRAIT = cursor.getString(cursor.getColumnIndex("cmtHeaderImage"));
                listBean.cId = cursor.getString(cursor.getColumnIndex("cmtFscID"));
                listBean.newtype = cursor.getString(cursor.getColumnIndex("cmtNewType"));
                listBeanArrayList.add(listBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listBeanArrayList;
    }

    //全部新消息
    public ArrayList<UserNewLy.ListBean> getAllNewInformationLy(String uid) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<UserNewLy.ListBean> listBeanArrayList = new ArrayList<>();

        String sql = "select * from CLCommentTable where cmtUserID !=" + uid + " order by cmtCreateTime desc , cmtSchID desc";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                UserNewLy.ListBean listBean = new UserNewLy.ListBean();
                listBean.uid = cursor.getString(cursor.getColumnIndex("cmtUserID"));
                listBean.opTime = cursor.getString(cursor.getColumnIndex("cmtOperateTime"));
                listBean.U_BACKGROUND_IMAGE = cursor.getString(cursor.getColumnIndex("cmtBackImage"));
                listBean.calendarId = cursor.getString(cursor.getColumnIndex("cmtSchID"));
                listBean.remark = cursor.getString(cursor.getColumnIndex("cmtSchContent"));
                listBean.changeTime = cursor.getString(cursor.getColumnIndex("cmtCreateTime"));
                listBean.mess = cursor.getString(cursor.getColumnIndex("cmtContent"));
                listBean.remark1 = cursor.getString(cursor.getColumnIndex("cmtSendName"));
                listBean.cType = cursor.getInt(cursor.getColumnIndex("cmtType"));
                listBean.remark2 = cursor.getString(cursor.getColumnIndex("cmtRemark2"));
                listBean.id = cursor.getInt(cursor.getColumnIndex("cmtMessageID"));
                listBean.schId = cursor.getString(cursor.getColumnIndex("cmtRemark"));
                listBean.U_NICK_NAME = cursor.getString(cursor.getColumnIndex("cmtNickName"));
                listBean.U_PORTRAIT = cursor.getString(cursor.getColumnIndex("cmtHeaderImage"));
                listBean.cId = cursor.getString(cursor.getColumnIndex("cmtFscID"));
                listBeanArrayList.add(listBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listBeanArrayList;
    }

    //存储新消息
    public void insertNewInformationLy(final UserNewLy.ListBean listBean) {
        //拿到数据库实例
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String updateSql = "select * from CLCommentTable where cmtMessageID='" + listBean.id + "'";

        try {
            int id = 0;
            Cursor cursor = sqldb.rawQuery(updateSql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex(listBean.id + ""));
            }
            cursor.close();
            if (id != 0) {
                updateNewInformationLy(listBean);
            } else {
                String StrFriend = "insert into CLCommentTable(" +
                        "cmtUserID," +
                        "cmtOperateTime," +
                        "cmtBackImage," +
                        "cmtSchID," +
                        "cmtSchContent, " +
                        "cmtCreateTime," +
                        "cmtContent," +
                        "cmtSendName  ," +
                        "cmtType," +
                        "cmtRemark2," +
                        "cmtMessageID," +
                        "cmtRemark," +
                        "cmtNickName," +
                        "cmtHeaderImage," +
                        "cmtFscID) "
                        + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                Object[] mValue = new Object[]{
                        StringUtils.getIsStringEqulesNull(listBean.uid),
                        StringUtils.getIsStringEqulesNull(listBean.opTime),
                        StringUtils.getIsStringEqulesNull(listBean.U_BACKGROUND_IMAGE),
                        StringUtils.getIsStringEqulesNull(listBean.calendarId),
                        StringUtils.getIsStringEqulesNull(listBean.remark + ""),
                        StringUtils.getIsStringEqulesNull(listBean.changeTime),
                        StringUtils.getIsStringEqulesNull(listBean.mess),
                        StringUtils.getIsStringEqulesNull(listBean.remark1 + ""),
                        StringUtils.getIsStringEqulesNull(listBean.cType + ""),
                        StringUtils.getIsStringEqulesNull(listBean.remark2 + ""),
                        StringUtils.getIsStringEqulesNull(listBean.id + ""),
                        StringUtils.getIsStringEqulesNull(listBean.schId),
                        StringUtils.getIsStringEqulesNull(listBean.U_NICK_NAME),
                        StringUtils.getIsStringEqulesNull(listBean.U_PORTRAIT),
                        StringUtils.getIsStringEqulesNull(listBean.cId),};
                try {
                    sqldb.execSQL(StrFriend, mValue);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //修改新消息
    public void updateNewInformationLy(UserNewLy.ListBean listBean) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update CLCommentTable set " +
                " cmtUserID ='" + listBean.uid +
                "' ,cmtOperateTime ='" + listBean.opTime +
                "' ,cmtBackImage ='" + listBean.U_BACKGROUND_IMAGE +
                "', cmtSchID ='" + listBean.calendarId +
                "' ,cmtSchContent = '" + listBean.remark +
                "' ,cmtCreateTime ='" + listBean.changeTime +
                "' ,cmtContent ='" + listBean.mess +
                "' ,cmtSendName ='" + listBean.remark1 +
                "' ,cmtType ='" + listBean.cType +
                "', cmtRemark2 ='" + listBean.remark2 +
                "' ,cmtRemark ='" + listBean.schId +
                "' ,cmtNickName ='" + listBean.U_NICK_NAME +
                "' ,cmtHeaderImage ='" + listBean.U_PORTRAIT +
                "' ,cmtFscID ='" + listBean.cId + "' where cmtMessageID=" + listBean.id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNewInforIsNew(String id) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update CLCommentTable set cmtIsNew = 1 where cmtSchID=" + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNewInforNewType(String id) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update CLCommentTable set cmtNewType = 1 where cmtMessageID=" + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //日程清单

    /**
     * 日程清单存储清单样式数量
     *
     * @param titleid
     * @param nums
     */
    public void saveCalenderNoteData(String titleid, String nums) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into CalenderNote(titleid,nums)" +
                "values(?,?)";
        Object[] value = new Object[]{
                titleid, nums,
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取日程清单样式数量
     *
     * @param titleid
     * @return
     */
    public String getCalenderNoteData(String titleid) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String nums = "0";
        String sql = "select * from CalenderNote where titleid = '" + titleid + "'";
        try {
            Cursor cursor = sqLiteDatabase.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                nums = cursor.getString(cursor.getColumnIndex("nums"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return nums;
    }


    // 重复推荐


    /**
     * 存储重复推荐分类
     *
     * @param bean
     */
    public void saveRepeatCommendData(RepeatRecommendTitle.PageBean.ItemsBean bean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_timepreinstall_recommend_type(id,orderby,name,titleImg,createTime," +
                "introduction,remark)" +
                "values(?,?,?,?,?,?,?)";
        Object[] value = new Object[]{
                bean.id,
                bean.orderby,
                StringUtils.getIsStringEqulesNull(bean.name),
                StringUtils.getIsStringEqulesNull(bean.titleImg),
                StringUtils.getIsStringEqulesNull(bean.createTime),
                bean.introduction,
                bean.remark,
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 存储重复推荐分类内
     *
     * @param bean
     */
    public void saveRepeatCommendContentData(RepeatRecommendContent.PageBean.ItemsBean bean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_timepreinstal_recommend_type_content(id,collectionCount,repUid,ctype,repTime,repType,repTypeParameter," +
                "repRingDesc,repRingCode,repContent,createTime,recommendName,remark,remark1)" +
                "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] value = new Object[]{
                bean.id,
                bean.collectionCount,
                bean.repUid,
                bean.ctype,
                StringUtils.getIsStringEqulesNull(bean.repTime),
                bean.repType,
                StringUtils.getIsStringEqulesNull(bean.repTypeParameter),
                StringUtils.getIsStringEqulesNull(bean.repRingDesc),
                StringUtils.getIsStringEqulesNull(bean.repRingCode),
                StringUtils.getIsStringEqulesNull(bean.repContent),
                StringUtils.getIsStringEqulesNull(bean.createTime),
                StringUtils.getIsStringEqulesNull(bean.recommendName),
                bean.remark,
                bean.remark1,
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询重复推荐类型
     *
     * @return
     */
    public List<RepeatRecommendTitle.PageBean.ItemsBean> getAllRepeatTypeData() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<RepeatRecommendTitle.PageBean.ItemsBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_timepreinstall_recommend_type order by orderby";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                RepeatRecommendTitle.PageBean.ItemsBean tDelListBean = new RepeatRecommendTitle.PageBean.ItemsBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.orderby = cursor.getInt(cursor.getColumnIndex("orderby"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.titleImg = cursor.getString(cursor.getColumnIndex("titleImg"));
                tDelListBean.name = cursor.getString(cursor.getColumnIndex("name"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.introduction = cursor.getString(cursor.getColumnIndex("introduction"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询重复推荐内容
     *
     * @return
     */
    public List<RepeatRecommendContent.PageBean.ItemsBean> getAllRepeatContentData(String ctype) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<RepeatRecommendContent.PageBean.ItemsBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_timepreinstal_recommend_type_content where ctype = " + ctype;

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                RepeatRecommendContent.PageBean.ItemsBean tDelListBean = new RepeatRecommendContent.PageBean.ItemsBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.repType = cursor.getInt(cursor.getColumnIndex("repType"));
                tDelListBean.repUid = cursor.getInt(cursor.getColumnIndex("repUid"));
                tDelListBean.ctype = cursor.getInt(cursor.getColumnIndex("ctype"));
                tDelListBean.collectionCount = cursor.getInt(cursor.getColumnIndex("collectionCount"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.repTime = cursor.getString(cursor.getColumnIndex("repTime"));
                tDelListBean.repTypeParameter = cursor.getString(cursor.getColumnIndex("repTypeParameter"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.repRingDesc = cursor.getString(cursor.getColumnIndex("repRingDesc"));
                tDelListBean.repRingCode = cursor.getString(cursor.getColumnIndex("repRingCode"));
                tDelListBean.repContent = cursor.getString(cursor.getColumnIndex("repContent"));
                tDelListBean.recommendName = cursor.getString(cursor.getColumnIndex("recommendName"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 删除重复推荐类型
     */
    public void deleteRepeatCommendData() {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "delete from tb_timepreinstall_recommend_type";
        try {
            sqLiteDatabase.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除重复推荐类型下所有内容
     *
     * @param ctype
     */
    public void deleteRepeatCommendTypeAllContentData(int ctype) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "delete from tb_timepreinstal_recommend_type_content where ctype = " + ctype;
        try {
            sqLiteDatabase.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    //******************清单************************

    /**
     * 储存清单标题表
     *
     * @param bean
     */

    public void saveNoteTitleData(NoteTitleDetailBean.TDelListBean bean) {

        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_user_detail_list_title(id,titleId,uid,titles,imgPath," +
                "imgUrl,shareUrl,filed,nums,copys,styles,ltype,orderId," +
                "createTime,changeTime,localTimes,remark,remark1,remark2,remark3,other1," +
                "other2,other3,other4,other5,puid,pname,states,sends,openState,other1) " +
                " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsIntEqulesNull(bean.id),
                StringUtils.getIsStringEqulesNull(bean.titleId),
                StringUtils.getIsIntEqulesNull(bean.uid),
                StringUtils.getIsStringEqulesNull(bean.titles),
                StringUtils.getIsStringEqulesNull(bean.imgPath),
                StringUtils.getIsStringEqulesNull(bean.imgUrl),
                StringUtils.getIsStringEqulesNull(bean.shareUrl),
                StringUtils.getIsStringEqulesNull(bean.filed),
                StringUtils.getIsStringEqulesNull(bean.nums),
                StringUtils.getIsStringEqulesNull(bean.copys),
                StringUtils.getIsIntEqulesNull(bean.styles),
                StringUtils.getIsIntEqulesNull(bean.ltype),
                StringUtils.getIsIntEqulesNull(bean.orderId),
                StringUtils.getIsStringEqulesNull(bean.createTime),
                StringUtils.getIsStringEqulesNull(bean.changeTime),
                StringUtils.getIsStringEqulesNull(bean.localTimes),
                (bean.remark == null || bean.remark.isEmpty()) ? "1" : bean.remark,
                (bean.remark1 == null || bean.remark1.isEmpty()) ? "0" : ((bean.remark1.equals("-1") ? "0" : bean.remark1)),
                (bean.remark2 == null || bean.remark2.isEmpty()) ? "0" : bean.remark2,
                bean.remark3, bean.remark4, bean.remark5, bean.remark6, bean.remark7, bean.remark8,
                StringUtils.getIsIntEqulesNull(bean.puid),
                StringUtils.getIsStringEqulesNull(bean.pname),
                StringUtils.getIsIntEqulesNull(bean.states),
                StringUtils.getIsIntEqulesNull(bean.sends),
                StringUtils.getIsIntEqulesNull(bean.openState),
                StringUtils.getIsStringEqulesNull(bean.other1),
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 修改收到的清单圆点状态
     *
     * @param userid
     * @param titleid
     */
    public void updateNoteTitleother1(int userid, String titleid) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set other1 = '0' where titleId = '" + titleid + "' and uid = " + userid;
        try {
            sqLiteDatabase.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取清单标题收到的清单未读数量
     *
     * @param userid
     * @return
     */
    public int getNoteTitleNotReadAll(String userid) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        int count = 0;
        String sql = "select * from tb_user_detail_list_title where other1 = '1' and uid = " + userid;
        try {
            Cursor cursor = sqLiteDatabase.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                count++;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return count;
    }

    /**
     * 存储新联系人数据
     *
     * @param bean
     */
    public void saveNewFriendData(NewFriendsActivity.newFriendBean.PageBean.ItemsBean bean, int updatastate) {


        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into NewFriendTable(puid,uid,id,type,pname,pimgs," +
                "changeTime,createTime,remark,remark1,updatastate)" +
                "values(?,?,?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsIntEqulesNull(bean.puid),
                StringUtils.getIsIntEqulesNull(bean.uid),
                StringUtils.getIsIntEqulesNull(bean.id),
                StringUtils.getIsIntEqulesNull(bean.type),
                StringUtils.getIsStringEqulesNull(bean.pname),
                StringUtils.getIsStringEqulesNull(bean.pimgs),
                StringUtils.getIsStringEqulesNull(bean.changeTime),
                StringUtils.getIsStringEqulesNull(bean.createTime),
                StringUtils.getIsStringEqulesNull(bean.remark),
                StringUtils.getIsStringEqulesNull(bean.remark1),
                updatastate,
        };

        String sq = "select * from NewFriendTable where puid = " + bean.puid;
        boolean issave = false;
        try {
            Cursor cursor = sqLiteDatabase.rawQuery(sq, null);
            while (cursor.moveToNext()) {
                if (cursor.getInt(cursor.getColumnIndex("puid")) == bean.puid) {
                    issave = true;
                    break;
                }
            }
            cursor.close();
            if (!issave) {
                sqLiteDatabase.execSQL(sql, value);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 查询当前用户的所有联系人
     *
     * @param userid
     * @param isupdata 是否同步
     * @return
     */
    public ArrayList<NewFriendsActivity.newFriendBean.PageBean.ItemsBean> getAllNewFriendData(String userid, boolean isupdata) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NewFriendsActivity.newFriendBean.PageBean.ItemsBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from NewFriendTable where uid = " + (userid.isEmpty() ? 0 : userid) + (isupdata ? " and updatastate != 0  and updatastate != -1 " : " and updatastate != 3 ");

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NewFriendsActivity.newFriendBean.PageBean.ItemsBean tDelListBean = new NewFriendsActivity.newFriendBean.PageBean.ItemsBean();
                tDelListBean.type = cursor.getInt(cursor.getColumnIndex("type"));
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.pimgs = cursor.getString(cursor.getColumnIndex("pimgs"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }


    public int getNewFriendUpdateState(int puid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        int updatestate = 0;

        String sql = "select * from NewFriendTable where puid = " + puid;

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatastate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return updatestate;
    }

    public int getAllNewFriendDataUpdataState(String id) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        int updatastate = 0;
        String sql = "select * from NewFriendTable where id = " + id;
        try {
            Cursor cursor = sqLiteDatabase.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatastate = cursor.getInt(cursor.getColumnIndex("updatastate"));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return updatastate;
    }

    public void updateNewFriendData(int uId, String uPortrait, String uname) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update NewFriendTable set pname = '" + uname + "' ,pimgs = '" + uPortrait + "' where puid = " + uId;
        try {
            sqLiteDatabase.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改日程已分享
     *
     * @param schID
     */
    public void updateSchRemark1(String schID, String schRemark4, String schRemark5, String schRemark51) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update ScheduleTable set schRemark1 = '1' , schRemark4 = '" + schRemark4 + "', where schID = " + schID;

        if (schRemark51 == null || schRemark51.isEmpty() || schRemark51.equals("0")) {
            sql = "update ScheduleTable set schRemark1 = '1' , schRemark4 = '" + schRemark4 + "', schRemark5 = '" + schRemark5 + "' where schID = " + schID;
        }
        try {
            sqLiteDatabase.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 存储清单分类数据
     *
     * @param bean
     */
    public void saveNoteTypeData(NoteTypeBean.ListBean bean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_user_detail_list_type(id,uid,content,orderId,changeTime,localId," +
                "remark,remark1,styleId)" +
                "values(?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsIntEqulesNull(bean.id),
                StringUtils.getIsIntEqulesNull(bean.uid),
                StringUtils.getIsStringEqulesNull(bean.content),
                StringUtils.getIsIntEqulesNull(bean.orderId),
                StringUtils.getIsStringEqulesNull(bean.changeTime),
                StringUtils.getIsIntEqulesNull(bean.localId),
                bean.remark,
                bean.remark1,
                StringUtils.getIsIntEqulesNull(bean.styleId),
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 下行状态修改
     *
     * @param titleId
     * @param id
     * @param states
     */
    public void updateCalenderNoteState(String titleId, int id, String states) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update tb_calendar_list_class1 set endstate = " + states
                + ",updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "' and id = " + id;
        try {
            sqLiteDatabase.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 下行状态修改
     *
     * @param titleId
     * @param id
     * @param states
     */
    public void updateNoteChildState(String titleId, int id, String states) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_class1 set endstate = " + states
                + ",updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "' and id = " + id;
        String sql1 = "update tb_user_detail_list_title set updatestate = " +
                "(case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "'";
        try {
            sqLiteDatabase.execSQL(sql);
            sqLiteDatabase.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNoteTitleColor(String titleId, String remark5, String remark6) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set other2 = '" + remark5 + "',other3 = '" + remark6 + "',updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "'";
        String sql1 = "update tb_user_detail_list_class1 set updatestate = " +
                "(case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "'";
        try {
            sqLiteDatabase.execSQL(sql);
            sqLiteDatabase.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNoteDetailColor(String titleId, int id, String remark3, String remark4) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_class1 set remark3 = '" + remark3 + "',remark4 = '" + remark4 + "',updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "' and id = " + id;
        String sql1 = "update tb_user_detail_list_title set updatestate = " +
                "(case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleId + "'";
        try {
            sqLiteDatabase.execSQL(sql);
            sqLiteDatabase.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /******
     * 清单日程
     * @TODO 清单日程
     */
    /**
     * 储存清单日程详情表
     *
     * @param bean
     */
    public void saveCalederNoteDetailData(CalenderNoteBean.PageBean.ItemsBean bean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_calendar_list_class1(id,uid,titleId,titles,contents,changeTime," +
                "orderId,imgPath,imgUrl,createTime,lType,style,endstate," +
                "nums,cpath,curl,shareUrl,sdesc,localIds,remark,remark1,remark2,remark3,remark4,remark5,remark6) " +
                "values(?,?,?,?,?,?,?,?,?,?," +
                "?,?,?,?,?,?,?,?,?,?," +
                "?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsIntEqulesNull(bean.getId()),
                StringUtils.getIsIntEqulesNull(bean.getUid()),
                StringUtils.getIsStringEqulesNull(bean.getTitleId()),
                StringUtils.getIsStringEqulesNull(bean.getTitles()),
                StringUtils.getIsStringEqulesNull(bean.getContents()),
                StringUtils.getIsStringEqulesNull(bean.getChangeTime()),
                StringUtils.getIsIntEqulesNull(bean.getOrderId()),
                StringUtils.getIsStringEqulesNull(bean.getImgPath()),
                StringUtils.getIsStringEqulesNull(bean.getImgUrl()),
                StringUtils.getIsStringEqulesNull(bean.getCreateTime()),
                StringUtils.getIsIntEqulesNull(bean.getLtype()),
                StringUtils.getIsIntEqulesNull(bean.getStyle()),
                StringUtils.getIsIntEqulesNull(bean.getEndstate()),
                StringUtils.getIsStringEqulesNull(bean.nums),
                StringUtils.getIsStringEqulesNull(bean.cpath),
                StringUtils.getIsStringEqulesNull(bean.curl),
                StringUtils.getIsStringEqulesNull(bean.shareUrl),
                StringUtils.getIsStringEqulesNull(bean.sdesc),
                StringUtils.getIsStringEqulesNull(bean.localIds),
                bean.remark,
                bean.remark1,
                bean.remark2,
                bean.remark3,
                bean.remark4, bean.remark5, bean.remark6,
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void saveSendRepeatNoteDetailData(UserFrendsTaskClass bean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_user_frends_task_class1(id,uId,titleId,titles,contents,changeTime," +
                "orderId,imgPath,imgUrl,createTime,lType,style,endstate," +
                "nums,cpath,curl,shareUrl,sdesc,localIds,remark,remark1," +
                "remark2,remark3,remark4,remark5,remark6,remark7,remark8,puId,ctype) " +
                "values(?,?,?,?,?,?,?,?,?,?," +
                "?,?,?,?,?,?,?,?,?,?," +
                "?,?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsIntEqulesNull(bean.getId()),
                StringUtils.getIsIntEqulesNull(bean.getuId()),
                StringUtils.getIsStringEqulesNull(bean.getTitleId()),
                StringUtils.getIsStringEqulesNull(bean.getTitles()),
                StringUtils.getIsStringEqulesNull(bean.getContents()),
                StringUtils.getIsStringEqulesNull(bean.getChangeTime()),
                StringUtils.getIsIntEqulesNull(bean.getOrderId()),
                StringUtils.getIsStringEqulesNull(bean.getImgPath()),
                StringUtils.getIsStringEqulesNull(bean.getImgUrl()),
                StringUtils.getIsStringEqulesNull(bean.getCreateTime()),
                StringUtils.getIsIntEqulesNull(bean.getlType()),
                StringUtils.getIsIntEqulesNull(bean.getStyle()),
                StringUtils.getIsIntEqulesNull(bean.getEndstate()),
                StringUtils.getIsStringEqulesNull(bean.nums),
                StringUtils.getIsStringEqulesNull(bean.cpath),
                StringUtils.getIsStringEqulesNull(bean.curl),
                StringUtils.getIsStringEqulesNull(bean.shareUrl),
                StringUtils.getIsStringEqulesNull(bean.sdesc),
                StringUtils.getIsStringEqulesNull(bean.localIds),
                bean.remark,
                bean.remark1,
                bean.remark2,
                bean.remark3,
                bean.remark4, bean.remark5, bean.remark6, bean.remark7, bean.remark8, StringUtils.getIsIntEqulesNull(bean.getPuId()), StringUtils.getIsIntEqulesNull(bean.getCtype()),
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 储存清单详情表
     *
     * @param bean
     */
    public void saveNoteDetailData(NoteTitleDetailBean.ListBean bean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();
        String sql = "replace into tb_user_detail_list_class1(id,titleId,uid,titles,imgPath,contents," +
                "imgUrl,shareUrl,endstate,nums,style,lType,orderId," +
                "createTime,changeTime,cpath,curl,remark,remark1,remark2,remark3,remark4) " +
                "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                StringUtils.getIsIntEqulesNull(bean.id),
                StringUtils.getIsStringEqulesNull(bean.titleId),
                StringUtils.getIsIntEqulesNull(bean.uid),
                StringUtils.getIsStringEqulesNull(bean.titles),
                StringUtils.getIsStringEqulesNull(bean.imgPath),
                StringUtils.getIsStringEqulesNull(bean.contents),
                StringUtils.getIsStringEqulesNull(bean.imgUrl),
                StringUtils.getIsStringEqulesNull(bean.shareUrl),
                StringUtils.getIsIntEqulesNull(bean.endstate),
                StringUtils.getIsStringEqulesNull(bean.nums),
                StringUtils.getIsIntEqulesNull(bean.style),
                StringUtils.getIsIntEqulesNull(bean.lType),
                StringUtils.getIsIntEqulesNull(bean.orderId),
                StringUtils.getIsStringEqulesNull(bean.createTime),
                StringUtils.getIsStringEqulesNull(bean.changetime),
                StringUtils.getIsStringEqulesNull(bean.cpath),
                StringUtils.getIsStringEqulesNull(bean.curl),
                bean.remark,
                bean.remark1,
                bean.remark2,
                bean.remark3,
                bean.remark4,
        };

        try {
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除清单日程子项
     *
     * @param dataId
     */
    public void deleteCalenderNote(int dataId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from tb_calendar_list_class1 where id = " + dataId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 根据type来删除清单数据
     *
     * @param type   12 详情 14 标题
     * @param dataId
     */
    public void deleteNote(int type, int dataId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "";
        if (type == 12) {
            sql = "delete from tb_user_detail_list_class1 where id = " + dataId;
        } else if (type == 14) {
            sql = "delete from tb_user_detail_list_title where id = " + dataId;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 查询当前用户的所有清单标题
     *
     * @param userid
     * @param isupdata 是否同步
     * @return
     */
    public List<NoteTitleDetailBean.TDelListBean> getAllNoteTitlesData(String userid, boolean isupdata, String remark1) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.TDelListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_title where uid = " + userid + (isupdata ? " and updatestate != 0  and updatestate != -1 " : " and updatestate != 3 ") + " and remark1 = '" + remark1 + "' order by changeTime";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.TDelListBean tDelListBean = new NoteTitleDetailBean.TDelListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("ltype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.filed = cursor.getString(cursor.getColumnIndex("filed"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.copys = cursor.getString(cursor.getColumnIndex("copys"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("other2"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("other3"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("other4"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("other5"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.sends = cursor.getInt(cursor.getColumnIndex("sends"));
                tDelListBean.states = cursor.getInt(cursor.getColumnIndex("states"));
                tDelListBean.openState = cursor.getInt(cursor.getColumnIndex("openState"));
                tDelListBean.other1 = cursor.getString(cursor.getColumnIndex("other1"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询当前用户的所有清单标题
     *
     * @param userid
     * @param isupdata 是否同步
     * @return
     */
    public List<NoteTitleDetailBean.TDelListBean> getAllNoteTitlesData(String userid, boolean isupdata) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.TDelListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_title where uid = " + userid + (isupdata ? " and updatestate != 0  and updatestate != -1 " : " and updatestate != 3 ") + " order by changeTime";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.TDelListBean tDelListBean = new NoteTitleDetailBean.TDelListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("ltype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.filed = cursor.getString(cursor.getColumnIndex("filed"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.copys = cursor.getString(cursor.getColumnIndex("copys"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("other2"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("other3"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("other4"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("other5"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.sends = cursor.getInt(cursor.getColumnIndex("sends"));
                tDelListBean.states = cursor.getInt(cursor.getColumnIndex("states"));
                tDelListBean.openState = cursor.getInt(cursor.getColumnIndex("openState"));
                tDelListBean.other1 = cursor.getString(cursor.getColumnIndex("other1"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 获取一条清单标题
     *
     * @param userid
     * @param titleid
     * @return
     */
    public NoteTitleDetailBean.TDelListBean getOneNoteTitlesData(String userid, String titleid, boolean isCalenderNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        NoteTitleDetailBean.TDelListBean tDelListBean = new NoteTitleDetailBean.TDelListBean();

        String sq = " and puid <= 0";

        String sql = "select * from tb_user_detail_list_title where uid = " + userid + " and titleId = '" + titleid + "'" + (isCalenderNote ? sq : "");

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {

                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("ltype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.filed = cursor.getString(cursor.getColumnIndex("filed"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.copys = cursor.getString(cursor.getColumnIndex("copys"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.sends = cursor.getInt(cursor.getColumnIndex("sends"));
                tDelListBean.states = cursor.getInt(cursor.getColumnIndex("states"));
                tDelListBean.openState = cursor.getInt(cursor.getColumnIndex("openState"));
                tDelListBean.other1 = cursor.getString(cursor.getColumnIndex("other1"));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBean;
    }

    /**
     * 查询当前用户的所有清单分类
     *
     * @param userid
     * @param isupdata 是否同步
     * @return
     */
    public List<NoteTypeBean.ListBean> getAllNoteTypeData(String userid, boolean isupdata) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTypeBean.ListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_type where uid = " + userid +
                (isupdata ? " and updatestate != 0  and updatestate != -1 " : " and updatestate != 3 ") + (isupdata ? " and orderId != 0 and orderId != -1" : " ") + " order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTypeBean.ListBean tDelListBean = new NoteTypeBean.ListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.content = cursor.getString(cursor.getColumnIndex("content"));
                tDelListBean.styleId = cursor.getInt(cursor.getColumnIndex("styleId"));
                tDelListBean.localId = cursor.getInt(cursor.getColumnIndex("localId"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    public String getNoteTitleChangeTime(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String swl = "select * from tb_user_detail_list_title where titleId = '" + titleid + "'";
        String time = DateUtil.formatDateTimeSs(new Date());
        try {
            Cursor cursor = sqldb.rawQuery(swl, null);
            while (cursor.moveToNext()) {
                time = cursor.getString(cursor.getColumnIndex("changeTime"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return time;
    }


    /**
     * 修改清单分类名称
     *
     * @param loaclid
     * @param name
     */
    public void updateNoteTypeName(String loaclid, String name) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_type set content = '" + name + "',updatestate = (case updatestate when 0 then 2 else updatestate end) where localId = " + loaclid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateCalenderTypeName(String ctgId, String name) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update CLCategoryTable set ctgText = '" + name + "',ctgUpdateState = (case ctgUpdateState when 0 then 2 else ctgUpdateState end) where ctgId = " + ctgId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNoteTypeName(int loaclid, String content, int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_type set id = " + id + ", content = '" + content + "'  where localId = " + loaclid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public int getNoteTypestate(String uid, int localid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int state = 0;
        String sql = "select * from tb_user_detail_list_type where uid = " + uid + " and localId = " + localid;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                state = cursor.getInt(cursor.getColumnIndex("updatestate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return state;
    }

    public int getCalenderTypestate(String ctgId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int state = 0;
        String sql = "select * from CLCategoryTable where ctgId = " + ctgId;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                state = cursor.getInt(cursor.getColumnIndex("ctgUpdateState"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return state;
    }


    public void updateAllNoteTypeState(String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_type set updatestate = 1 where uid = " + userid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNoteTyeOrderId(int orderid, int localid, String uid, String name, int updatestate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_type set updatestate = " + updatestate + ", orderId = " +
                orderid + ", content = '" + name + "' where localId = " + localid + " and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateClanderTyeOrderId(int orderid, String ctgId, String name, int updatestate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update CLCategoryTable set ctgUpdateState = " + updatestate + ", ctgOrder = " +
                orderid + ", ctgText = '" + name + "' where ctgId = " + ctgId;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNoteTitleSort(String localTimes, String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set updatestate = (case updatestate when 0 then 2 else updatestate end), localTimes = '"
                + localTimes + "' where titleid = '" + titleid + "'";//+ " and uid = " + uid
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单分类状态
     *
     * @param loaclid
     * @param updatestate
     */
    public void updateNoteTypeState(int loaclid, int updatestate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_type set updatestate = " + updatestate + " where localId = " + loaclid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单分类
     *
     * @param titleid
     * @param styleid
     */
    public void updateNoteChildType(String titleid, int styleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set updatestate = (case updatestate when 0 then 2 else updatestate end), remark1 = '" + styleid + "' where titleId = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题的本地时间
     *
     * @param titleid
     * @param localtime
     */
    public void updateNoteTitleLocalTimes(String titleid, String localtime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set updatestate = (case updatestate when 0 then 2 else updatestate end), localTimes = '" + localtime + "' where titleId = '" + titleid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateNoteTyeOrderId(int locaid1, int localid2, int orderid1, int orderid2) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_type set orderId = " + orderid1 + " where localId = " + locaid1;
        String sql1 = "update tb_user_detail_list_type set orderId = " + orderid2 + " where localId = " + localid2;
        String sql3 = "update tb_user_detail_list_type set updatestate = (case updatestate when 0 then 2 else updatestate end)";
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
            sqldb.execSQL(sql3);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 复制一个清单标题到库
     *
     * @param userid
     * @param titleid
     */
    public void copyNoteTitleData(String userid, String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String newtitleid = DateUtil.nowTime1();
        String sql = "insert into tb_user_detail_list_title (id,titleId,uid,titles,imgPath," +
                "imgUrl,shareUrl,filed,nums,copys,styles,ltype,orderId," +
                "createTime,changeTime,localTimes,remark,remark1,remark2,remark3,other1,other2,other3,other4,other5,puid,pname,states,sends,updatestate,openState,other1)" +
                " select " + (getTiMinId() - 1) + ",'" + newtitleid + "',uid,titles,imgPath," +
                "imgUrl,shareUrl,filed,nums,copys,styles,ltype,orderId," +
                "createTime,changeTime,localTimes,remark,remark1,remark2,remark3,other1,other2,other3,other4,other5,puid,pname,states,sends,1,openState,other1 from tb_user_detail_list_title" +
                " where titleId = '" + titleid + "' and uid = " + userid;

        List<NoteTitleDetailBean.ListBean> list = getTitleNoteDetailData(userid, titleid, false);
        for (NoteTitleDetailBean.ListBean bean : list) {
            bean.id = getMinId() - 1;
            bean.titleId = newtitleid;
            saveNoteDetailData(bean);
            updateNoteTitleDetailState(newtitleid, bean.id, userid, 1, true);
        }

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public boolean copySendRepeatNoteData(int id, String userid, String maxTitleId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String newtitleid = DateUtil.nowTime1();
        String sql = "insert into tb_user_frends_task (id,uId,ctype,ptype,uname," +
                "pname,titleImg,puId,pDeleState,content,cdate,ctime,repInSTable," +
                "repType,repTypeParameter,cIsAlarm,cBeforTime,cAlarmSound,cAlarmSoundDesc,cDisplayAlarm" +
                ",cPostpone,cImportant,pIsEnd,cIsEnd,styles,cIsDown,cColorType,createTime,changTime," +
                "titleId,remark,remark1,remark2,remark3,remark4,remark5,remark6,updatestate)" +
                " select " + (getSendRepeatNoteMinId() - 1) + ",uId,ctype,ptype,uname," +
                "pname,titleImg,puId,pDeleState,content,cdate,ctime,repInSTable," +
                "repType,repTypeParameter,cIsAlarm,cBeforTime,cAlarmSound,cAlarmSoundDesc,cDisplayAlarm" +
                ",cPostpone,cImportant,pIsEnd,cIsEnd,styles,cIsDown,cColorType,'" + DateUtil.formatDateTime(new Date()) + "','" + DateUtil.formatDateTime(new Date()) + "'," +
                "'" + newtitleid + "',remark,remark1,remark2,remark3,remark4,remark5,remark6,1 from tb_user_frends_task" +
                " where id = " + id;

        try {
            sqldb.execSQL(sql);
            List<UserFrendsTaskClass> list = getSendRepeatNoteDetailData(userid, maxTitleId, false);
            for (UserFrendsTaskClass bean : list) {
                bean.id = getSendRepeatNoteChildMinId() - 1;
                bean.titleId = newtitleid;
                saveSendRepeatNoteDetailData(bean);
                updateSendRepeatNoteDetailState(maxTitleId, bean.id, userid, 1, true);
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 复制一个清单日程到库
     *
     * @param userid
     * @param titleid
     */
    public void copyCalnederNoteData(String userid, String schID, String titleid, String date) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String nettled = DateUtil.nowTime1();
        String sql = "insert into ScheduleTable (ID,schID,schContent,schDate,schTime," +
                "schIsAlarm,schBeforeTime,schDisplayTime,schIsPostpone,schIsImportant,schColorType,schIsEnd,schCreateTime," +
                "schTags,schSourceType,schSourceDesc,schSourceDescSpare,schRepeatID,schRepeatDate," +
                "schUpdateTime,schOpenState,schRepeatLink,schRingDesc,schRingCode,schcRecommendName,schRead,schAID," +
                "schAType,schWebURL,schImagePath,schFocusState,schFriendID,schcRecommendId,schUpdateState," +
                "schpisEnd,schRemark1,schRemark2,schRemark3,schRemark4,schRemark5)" +
                " select " + getLocalId(1, "ScheduleTable", ScheduleTable.ID) + "," + getLocalId(-1, "ScheduleTable", ScheduleTable.schID) + "," +
                "schContent,'" + date + "',schTime," +
                "schIsAlarm,schBeforeTime,schDisplayTime,schIsPostpone,schIsImportant,schColorType,schIsEnd,schCreateTime," +
                "schTags,schSourceType,'" + nettled + "',schSourceDescSpare,0,''," +
                "schUpdateTime,schOpenState,0,schRingDesc,schRingCode,'',schRead,schAID," +
                "schAType,schWebURL,schImagePath,schFocusState,schFriendID,0,1,schpisEnd,'0',schRemark2,schRemark3,schRemark4,schRemark5 from ScheduleTable" +
                " where schID = " + schID;

        List<CalenderNoteBean.PageBean.ItemsBean> list = getCalenderNoteDetailData(userid, titleid, false);
        for (CalenderNoteBean.PageBean.ItemsBean bean : list) {
            bean.id = gettb_calendar_list_class1MinId() - 1;
            bean.titleId = nettled;
            saveCalederNoteDetailData(bean);
            updateCalenderNoteDetailState(nettled, bean.id, userid, 1, true);
        }

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取是否归档的清单
     *
     * @param userid
     * @param filed  0  我的  1  归档
     * @return
     */
    public ArrayList<NoteTitleDetailBean.TDelListBean> getFiledNoteTitlesData(String userid, String filed) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.TDelListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_title where uid = " + userid + " and updatestate != 3  order by changeTime";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.TDelListBean tDelListBean = new NoteTitleDetailBean.TDelListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("ltype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.filed = cursor.getString(cursor.getColumnIndex("filed"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.copys = cursor.getString(cursor.getColumnIndex("copys"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("other2"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("other3"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("other4"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("other5"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.sends = cursor.getInt(cursor.getColumnIndex("sends"));
                tDelListBean.states = cursor.getInt(cursor.getColumnIndex("states"));
                tDelListBean.openState = cursor.getInt(cursor.getColumnIndex("openState"));
                tDelListBean.other1 = cursor.getString(cursor.getColumnIndex("other1"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询不同归档的分类清单
     *
     * @param userid
     * @param filed
     * @param remark1
     * @return
     */
    public ArrayList<NoteTitleDetailBean.TDelListBean> getFiledNoteTitlesTypeData(String userid, String filed, String remark1) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.TDelListBean> tDelListBeanArrayList = new ArrayList<>();
        //String sql = "select * from tb_user_detail_list_title where uid = " + userid + (filed.equals("1") ? " and filed = '1' " : " and filed != '1' ") + " and updatestate != 3 and remark1 = '" + remark1 + "' group by titleId order by changeTime";
        String sql = "select * from tb_user_detail_list_title where uid = " + userid + " and updatestate != 3 group by titleId order by changeTime";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.TDelListBean tDelListBean = new NoteTitleDetailBean.TDelListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("ltype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.filed = cursor.getString(cursor.getColumnIndex("filed"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.copys = cursor.getString(cursor.getColumnIndex("copys"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("other2"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("other3"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("other4"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("other5"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.sends = cursor.getInt(cursor.getColumnIndex("sends"));
                tDelListBean.states = cursor.getInt(cursor.getColumnIndex("states"));
                tDelListBean.openState = cursor.getInt(cursor.getColumnIndex("openState"));
                tDelListBean.other1 = cursor.getString(cursor.getColumnIndex("other1"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }


    /**
     * 查询不同归档的分类清单dialog
     *
     * @param userid
     * @param filed
     * @param remark1
     * @return
     */
    public ArrayList<NoteTitleDetailBean.TDelListBean> getFiledNoteTitlesTypeDataDialog(String userid, String filed, String remark1) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.TDelListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_title where uid = " + userid + (filed.equals("1") ? " and filed = '1' " : " and filed != '1' ") + " and updatestate != 3 and remark1 = '" + remark1 + "' and remark3 not in('1','2') order by changeTime";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.TDelListBean tDelListBean = new NoteTitleDetailBean.TDelListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("ltype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.filed = cursor.getString(cursor.getColumnIndex("filed"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.copys = cursor.getString(cursor.getColumnIndex("copys"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("other2"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("other3"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("other4"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("other5"));
                tDelListBean.puid = cursor.getInt(cursor.getColumnIndex("puid"));
                tDelListBean.pname = cursor.getString(cursor.getColumnIndex("pname"));
                tDelListBean.sends = cursor.getInt(cursor.getColumnIndex("sends"));
                tDelListBean.states = cursor.getInt(cursor.getColumnIndex("states"));
                tDelListBean.openState = cursor.getInt(cursor.getColumnIndex("openState"));
                tDelListBean.other1 = cursor.getString(cursor.getColumnIndex("other1"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询当前用户的所有清单日程详情
     *
     * @param userid
     * @param isupdata 是否为同步
     * @return
     */
    public List<CalenderNoteBean.PageBean.ItemsBean> getAllCalenderNoteDetailData(String userid, boolean isupdata) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<CalenderNoteBean.PageBean.ItemsBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_calendar_list_class1 where uid = '" + userid + (isupdata ? "' and updatestate != -1  and updatestate != 0 " : "' and updatestate != 3 ") + " order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                CalenderNoteBean.PageBean.ItemsBean tDelListBean = new CalenderNoteBean.PageBean.ItemsBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.style = cursor.getInt(cursor.getColumnIndex("style"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("lType"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.endstate = cursor.getInt(cursor.getColumnIndex("endstate"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.contents = cursor.getString(cursor.getColumnIndex("contents"));
                tDelListBean.cpath = cursor.getString(cursor.getColumnIndex("cpath"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.curl = cursor.getString(cursor.getColumnIndex("curl"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.sdesc = cursor.getString(cursor.getColumnIndex("sdesc"));
                tDelListBean.localIds = cursor.getString(cursor.getColumnIndex("localIds"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("remark5"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("remark6"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询当前用户的所有清单详情
     *
     * @param userid
     * @param isupdata 是否为同步
     * @return
     */
    public List<NoteTitleDetailBean.ListBean> getAllNoteDetailData(String userid, boolean isupdata) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.ListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_class1 where uid = '" + userid + (isupdata ? "' and updatestate != -1  and updatestate != 0 " : "' and updatestate != 3 ") + " order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.ListBean tDelListBean = new NoteTitleDetailBean.ListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.style = cursor.getInt(cursor.getColumnIndex("style"));
                tDelListBean.lType = cursor.getInt(cursor.getColumnIndex("lType"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.endstate = cursor.getInt(cursor.getColumnIndex("endstate"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.contents = cursor.getString(cursor.getColumnIndex("contents"));
                tDelListBean.cpath = cursor.getString(cursor.getColumnIndex("cpath"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.curl = cursor.getString(cursor.getColumnIndex("curl"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changetime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询当前用户的titleid所有清单详情
     *
     * @param userid
     * @param titleId
     * @return
     */
    public List<NoteTitleDetailBean.ListBean> getTitleNoteDetailData(String userid, String titleId, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<NoteTitleDetailBean.ListBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_detail_list_class1 where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and titleId = '" + titleId + "' order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteTitleDetailBean.ListBean tDelListBean = new NoteTitleDetailBean.ListBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.style = cursor.getInt(cursor.getColumnIndex("style"));
                tDelListBean.lType = cursor.getInt(cursor.getColumnIndex("lType"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.endstate = cursor.getInt(cursor.getColumnIndex("endstate"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.contents = cursor.getString(cursor.getColumnIndex("contents"));
                tDelListBean.cpath = cursor.getString(cursor.getColumnIndex("cpath"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.curl = cursor.getString(cursor.getColumnIndex("curl"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.changetime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * 查询当前用户的titleid所有清单日程详情
     *
     * @param userid
     * @param titleId
     * @return
     */
    public List<CalenderNoteBean.PageBean.ItemsBean> getCalenderNoteDetailData(String userid, String titleId, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<CalenderNoteBean.PageBean.ItemsBean> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_calendar_list_class1 where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and titleId = '" + titleId + "' order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                CalenderNoteBean.PageBean.ItemsBean tDelListBean = new CalenderNoteBean.PageBean.ItemsBean();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                tDelListBean.style = cursor.getInt(cursor.getColumnIndex("style"));
                tDelListBean.ltype = cursor.getInt(cursor.getColumnIndex("lType"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.endstate = cursor.getInt(cursor.getColumnIndex("endstate"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.contents = cursor.getString(cursor.getColumnIndex("contents"));
                tDelListBean.cpath = cursor.getString(cursor.getColumnIndex("cpath"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.curl = cursor.getString(cursor.getColumnIndex("curl"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.sdesc = cursor.getString(cursor.getColumnIndex("sdesc"));
                tDelListBean.localIds = cursor.getString(cursor.getColumnIndex("localIds"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("remark5"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("remark6"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    public List<UserFrendsTask> getAllSendRepeatNoteData(String userid, int puId, int repType, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        ArrayList<UserFrendsTask> userFrendsTasks = new ArrayList<>();
        String sql = "select * from tb_user_frends_task where uid = " + userid + " "
                + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + (repType == -1 ? " " : " and repType = " + repType) +
                " and puId = " + puId + " order by repType asc,cdate asc,ctime asc";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                UserFrendsTask task = new UserFrendsTask();
                task.id = cursor.getInt(cursor.getColumnIndex("id"));
                task.uId = cursor.getInt(cursor.getColumnIndex("uId"));
                task.ctype = cursor.getInt(cursor.getColumnIndex("ctype"));
                task.ptype = cursor.getInt(cursor.getColumnIndex("ptype"));
                task.puId = cursor.getInt(cursor.getColumnIndex("puId"));
                task.pDeleState = cursor.getInt(cursor.getColumnIndex("pDeleState"));
                task.repInSTable = cursor.getInt(cursor.getColumnIndex("repInSTable"));
                task.repType = cursor.getInt(cursor.getColumnIndex("repType"));
                task.cBeforTime = cursor.getInt(cursor.getColumnIndex("cBeforTime"));
                task.cDisplayAlarm = cursor.getInt(cursor.getColumnIndex("cDisplayAlarm"));
                task.cPostpone = cursor.getInt(cursor.getColumnIndex("cPostpone"));
                task.cImportant = cursor.getInt(cursor.getColumnIndex("cImportant"));
                task.pIsEnd = cursor.getInt(cursor.getColumnIndex("pIsEnd"));
                task.cIsEnd = cursor.getInt(cursor.getColumnIndex("cIsEnd"));
                task.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                task.cIsDown = cursor.getInt(cursor.getColumnIndex("cIsDown"));
                task.cColorType = cursor.getInt(cursor.getColumnIndex("cColorType"));
                task.uname = cursor.getString(cursor.getColumnIndex("uname"));
                task.pname = cursor.getString(cursor.getColumnIndex("pname"));
                task.titleImg = cursor.getString(cursor.getColumnIndex("titleImg"));
                task.content = cursor.getString(cursor.getColumnIndex("content"));
                task.cdate = cursor.getString(cursor.getColumnIndex("cdate"));
                task.ctime = cursor.getString(cursor.getColumnIndex("ctime"));
                task.repTypeParameter = cursor.getString(cursor.getColumnIndex("repTypeParameter"));
                task.cIsAlarm = cursor.getString(cursor.getColumnIndex("cIsAlarm"));
                task.cAlarmSound = cursor.getString(cursor.getColumnIndex("cAlarmSound"));
                task.cAlarmSoundDesc = cursor.getString(cursor.getColumnIndex("cAlarmSoundDesc"));
                task.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                task.changTime = cursor.getString(cursor.getColumnIndex("changTime"));
                task.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                task.remark = cursor.getString(cursor.getColumnIndex("remark"));
                task.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                task.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                task.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                task.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                task.remark5 = cursor.getString(cursor.getColumnIndex("remark5"));
                task.remark6 = cursor.getString(cursor.getColumnIndex("remark6"));
                userFrendsTasks.add(task);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return userFrendsTasks;
    }

    public UserFrendsTask getOneSendRepeatNoteData(String userid, int puId, String titleId, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        UserFrendsTask task = new UserFrendsTask();
        String sql = "select * from tb_user_frends_task where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and puId = " + puId + " and titleId = '" + titleId + "' order by repType asc,cdate asc,ctime asc";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {

                task.id = cursor.getInt(cursor.getColumnIndex("id"));
                task.uId = cursor.getInt(cursor.getColumnIndex("uId"));
                task.ctype = cursor.getInt(cursor.getColumnIndex("ctype"));
                task.ptype = cursor.getInt(cursor.getColumnIndex("ptype"));
                task.puId = cursor.getInt(cursor.getColumnIndex("puId"));
                task.pDeleState = cursor.getInt(cursor.getColumnIndex("pDeleState"));
                task.repInSTable = cursor.getInt(cursor.getColumnIndex("repInSTable"));
                task.repType = cursor.getInt(cursor.getColumnIndex("repType"));
                task.cBeforTime = cursor.getInt(cursor.getColumnIndex("cBeforTime"));
                task.cDisplayAlarm = cursor.getInt(cursor.getColumnIndex("cDisplayAlarm"));
                task.cPostpone = cursor.getInt(cursor.getColumnIndex("cPostpone"));
                task.cImportant = cursor.getInt(cursor.getColumnIndex("cImportant"));
                task.pIsEnd = cursor.getInt(cursor.getColumnIndex("pIsEnd"));
                task.cIsEnd = cursor.getInt(cursor.getColumnIndex("cIsEnd"));
                task.styles = cursor.getInt(cursor.getColumnIndex("styles"));
                task.cIsDown = cursor.getInt(cursor.getColumnIndex("cIsDown"));
                task.cColorType = cursor.getInt(cursor.getColumnIndex("cColorType"));
                task.uname = cursor.getString(cursor.getColumnIndex("uname"));
                task.pname = cursor.getString(cursor.getColumnIndex("pname"));
                task.titleImg = cursor.getString(cursor.getColumnIndex("titleImg"));
                task.content = cursor.getString(cursor.getColumnIndex("content"));
                task.cdate = cursor.getString(cursor.getColumnIndex("cdate"));
                task.ctime = cursor.getString(cursor.getColumnIndex("ctime"));
                task.repTypeParameter = cursor.getString(cursor.getColumnIndex("repTypeParameter"));
                task.cIsAlarm = cursor.getString(cursor.getColumnIndex("cIsAlarm"));
                task.cAlarmSound = cursor.getString(cursor.getColumnIndex("cAlarmSound"));
                task.cAlarmSoundDesc = cursor.getString(cursor.getColumnIndex("cAlarmSoundDesc"));
                task.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                task.changTime = cursor.getString(cursor.getColumnIndex("changTime"));
                task.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                task.remark = cursor.getString(cursor.getColumnIndex("remark"));
                task.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                task.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                task.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                task.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                task.remark5 = cursor.getString(cursor.getColumnIndex("remark5"));
                task.remark6 = cursor.getString(cursor.getColumnIndex("remark6"));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return task;
    }

    public int getOneSendRepeatNoteUpdatestate(String userid, int puId, String titleId, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int updatestate = 0;
        String sql = "select * from tb_user_frends_task where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and puId = " + puId + " and titleId = '" + titleId + "' order by repType asc,cdate asc,ctime asc";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatestate"));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return updatestate;
    }

    public int getOneSendRepeatNoteDetailUpdatestate(String userid, int puId, String titleId, int id, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        int updatestate = 0;
        String sql = "select * from tb_user_frends_task_class1 where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and titleId = '" + titleId + "' and id = " + id + " order by orderId";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatestate"));
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return updatestate;
    }

    public List<UserFrendsTaskClass> getAllSendRepeatNoteDetailData(String userid, int puid, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<UserFrendsTaskClass> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_frends_task_class1 where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and puId = '" + puid + "' order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                UserFrendsTaskClass tDelListBean = new UserFrendsTaskClass();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.uId = cursor.getInt(cursor.getColumnIndex("uId"));
                tDelListBean.puId = cursor.getInt(cursor.getColumnIndex("puId"));
                tDelListBean.ctype = cursor.getInt(cursor.getColumnIndex("ctype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.lType = cursor.getInt(cursor.getColumnIndex("lType"));
                tDelListBean.style = cursor.getInt(cursor.getColumnIndex("style"));
                tDelListBean.endstate = cursor.getInt(cursor.getColumnIndex("endstate"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.contents = cursor.getString(cursor.getColumnIndex("contents"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.cpath = cursor.getString(cursor.getColumnIndex("cpath"));
                tDelListBean.curl = cursor.getString(cursor.getColumnIndex("curl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.sdesc = cursor.getString(cursor.getColumnIndex("sdesc"));
                tDelListBean.localIds = cursor.getString(cursor.getColumnIndex("localIds"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("remark5"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("remark6"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("remark7"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("remark8"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    public List<UserFrendsTaskClass> getSendRepeatNoteDetailData(String userid, String titleId, boolean isSyn) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<UserFrendsTaskClass> tDelListBeanArrayList = new ArrayList<>();

        String sql = "select * from tb_user_frends_task_class1 where uid = " + userid + " " + (isSyn ? " and updatestate != 0 " : " and updatestate != 3 ") + " and titleId = '" + titleId + "' order by orderId";

        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                UserFrendsTaskClass tDelListBean = new UserFrendsTaskClass();
                tDelListBean.id = cursor.getInt(cursor.getColumnIndex("id"));
                tDelListBean.uId = cursor.getInt(cursor.getColumnIndex("uId"));
                tDelListBean.puId = cursor.getInt(cursor.getColumnIndex("puId"));
                tDelListBean.ctype = cursor.getInt(cursor.getColumnIndex("ctype"));
                tDelListBean.orderId = cursor.getInt(cursor.getColumnIndex("orderId"));
                tDelListBean.lType = cursor.getInt(cursor.getColumnIndex("lType"));
                tDelListBean.style = cursor.getInt(cursor.getColumnIndex("style"));
                tDelListBean.endstate = cursor.getInt(cursor.getColumnIndex("endstate"));
                tDelListBean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                tDelListBean.titles = cursor.getString(cursor.getColumnIndex("titles"));
                tDelListBean.contents = cursor.getString(cursor.getColumnIndex("contents"));
                tDelListBean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                tDelListBean.imgPath = cursor.getString(cursor.getColumnIndex("imgPath"));
                tDelListBean.imgUrl = cursor.getString(cursor.getColumnIndex("imgUrl"));
                tDelListBean.createTime = cursor.getString(cursor.getColumnIndex("createTime"));
                tDelListBean.nums = cursor.getString(cursor.getColumnIndex("nums"));
                tDelListBean.cpath = cursor.getString(cursor.getColumnIndex("cpath"));
                tDelListBean.curl = cursor.getString(cursor.getColumnIndex("curl"));
                tDelListBean.shareUrl = cursor.getString(cursor.getColumnIndex("shareUrl"));
                tDelListBean.sdesc = cursor.getString(cursor.getColumnIndex("sdesc"));
                tDelListBean.localIds = cursor.getString(cursor.getColumnIndex("localIds"));
                tDelListBean.remark = cursor.getString(cursor.getColumnIndex("remark"));
                tDelListBean.remark1 = cursor.getString(cursor.getColumnIndex("remark1"));
                tDelListBean.remark2 = cursor.getString(cursor.getColumnIndex("remark2"));
                tDelListBean.remark3 = cursor.getString(cursor.getColumnIndex("remark3"));
                tDelListBean.remark4 = cursor.getString(cursor.getColumnIndex("remark4"));
                tDelListBean.remark5 = cursor.getString(cursor.getColumnIndex("remark5"));
                tDelListBean.remark6 = cursor.getString(cursor.getColumnIndex("remark6"));
                tDelListBean.remark7 = cursor.getString(cursor.getColumnIndex("remark7"));
                tDelListBean.remark8 = cursor.getString(cursor.getColumnIndex("remark8"));
                tDelListBeanArrayList.add(tDelListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return tDelListBeanArrayList;
    }

    /**
     * titleid的第一条有内容的清单日程内容
     *
     * @param userid
     * @param titleId
     * @return
     */
    public String getCalenderNoteDetailContent(String userid, String titleId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String title = "";

        String sql = "select contents from tb_calendar_list_class1 where contents != '' and uid = " + userid + " and titleId = '" + titleId + "' and updatestate != 3 order by orderId";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                title = cursor.getString(cursor.getColumnIndex("contents"));
                if (!title.isEmpty()) {
                    if (title.length() > 50) {
                        title = title.substring(0, 50);
                    }
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return title;
    }

    /**
     * titleid的第一条有内容的清单内容
     *
     * @param userid
     * @param titleId
     * @return
     */
    public String getNoteTitleDetailContent(String userid, String titleId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String title = "";

        String sql = "select contents from tb_user_detail_list_class1 where contents != '' and uid = " + userid + " and titleId = '" + titleId + "' and updatestate != 3 order by orderId";
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                title = cursor.getString(cursor.getColumnIndex("contents"));
                if (!title.isEmpty()) {
                    if (title.length() > 50) {
                        title = title.substring(0, 50);
                    }
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return title;
    }


    /**
     * 判断当前标题是否有图片
     *
     * @param userid
     * @param titleId
     * @return
     */
    public boolean getNoteTitleImage(String userid, String titleId) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        boolean isImage = false;

        String sql = "select imgPath from tb_user_detail_list_title where titleId = '" + titleId + "' and uid = " + userid;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                if (!cursor.getString(cursor.getColumnIndex("imgPath")).isEmpty()) {
                    isImage = true;
                    break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        return isImage;
    }

    public boolean getNoteTitleother1(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String swl = "select * from tb_user_detail_list_title where titleId = '" + titleid + "'";
        boolean other2 = false;
        try {
            Cursor cursor = sqldb.rawQuery(swl, null);
            while (cursor.moveToNext()) {
                String i = cursor.getString(cursor.getColumnIndex("other1"));
                if (i.equals("1")) {
                    other2 = true;
                }
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return other2;
    }

    /**
     * 清单红点 留言
     *
     * @param titleid
     * @param uid
     */
    public void updateNoteTitleOther1(String titleid, String uid, int other1) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set other1 = '" + other1
                + "', updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '"
                + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 清单红点 留言
     *
     * @param titleid
     * @param uid
     * @param changeTime
     */
    public void updateNoteTitleOther1(String titleid, String uid, String changeTime) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set other1 = '1', changeTime = '" + changeTime +
                "', updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '"
                + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public void updateSendRepeatNotePause(int id, String remark2) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task set remark2 = '" + remark2 +
                "', updatestate = (case updatestate when 0 then 2 else updatestate end) where id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题状态 1 新建 2 修改 3 删除 4 异常 0 不处理
     *
     * @param id
     * @param uid
     * @param state
     * @param issyn 是否在同步
     */
    public void updateNoteTitleState(String id, String uid, int state, boolean issyn) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set updatestate = " + state + (issyn ? " where id = " + id : " where titleId = '" + id + "'") + " and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteTitleState(int id, String uid, int state, boolean issyn) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task set updatestate = " + state + (issyn ? " where id = " + id : " where titleId = '" + id + "'") + " and uId = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改titleid下的详情状态
     *
     * @param titleid
     * @param uid
     * @param state
     */
    public void updateNoteTitleDetailState(String titleid, String uid, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 set updatestate = " + state + " where titleId = '" + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程下的详情状态
     *
     * @param titleid
     * @param uid
     * @param state
     */
    public void updateCalenderNoteDetailState(String titleid, String uid, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_calendar_list_class1 set updatestate = " + state + " where titleId = '" + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题详情状态 1 新建 2 修改 3 删除 4 异常 0 不处理
     *
     * @param titleid
     * @param id
     * @param uid
     * @param state
     * @param issyn   是否在同步
     */
    public void updateNoteTitleDetailState(String titleid, int id, String uid, int state, boolean issyn) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 set updatestate = " + state + " " + (issyn ? "where" : " where titleId = '" + titleid + "' and ") + " id = " + id + " and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetailState(String titleid, int id, String uid, int state, boolean issyn) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 set updatestate = " + state + " " + (issyn ? "where" : " where titleId = '" + titleid + "' and ") + " id = " + id + " and uId = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程详情状态 1 新建 2 修改 3 删除 4 异常 0 不处理
     *
     * @param titleid
     * @param id
     * @param uid
     * @param state
     * @param issyn   是否在同步
     */
    public void updateCalenderNoteDetailState(String titleid, int id, String uid, int state, boolean issyn) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_calendar_list_class1 set updatestate = " + state + " " + (issyn ? "where" : " where titleId = '" + titleid + "' and ") + " id = " + id + " and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetailState(String id, String uid, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 set updatestate = " + state + " where id = " + id + " and uId = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetailState(int id, String uid, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 set updatestate = " + state + " where id = " + id + " and uId = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改联系人状态
     *
     * @param id
     * @param uid
     * @param state
     */
    public void updateNewFriendState(int id, String uid, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update NewFriendTable set updatastate = " + state + " where id = " + id + " and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteUpdatestate(String titleId, int id, int updatestate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task set updatestate = " + ((updatestate == 1) ? updatestate : "(case updatestate when 0 then 2 else updatestate end)") + " where titleId = '" + titleId + "' and  id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单的归档
     *
     * @param titleId
     * @param uid
     * @param filed
     */
    public void updateNoteTitleFiled(String titleId, int uid, int filed) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set updatestate = (case updatestate when 0 then 2 else updatestate end), filed = '" + filed + "' where titleId = '" + titleId + "' and  uid = " + uid;
        String sql2 = "update tb_user_detail_list_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end), remark2 = '" + filed + "' where titleId = '" + titleId + "' and  uid = " + uid;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 新游客正式修改状态
     */
    public void updateNoteSate(String uid) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql1 = "update tb_user_detail_list_title set uid = " + uid + ",updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId != '0111' and titleId != '1111' and titleId != '2111'";
        String sql2 = "update tb_user_detail_list_class1 set uid = " + uid + " ,updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId != '0111' and titleId != '1111' and titleId != '2111'";
        String sql15 = "update tb_calendar_list_class1 set uid = " + uid + " ,updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId != '0111' and titleId != '1111' and titleId != '2111'";
        String sql4 = "update NewFriendTable set uid = " + uid + " ,updatastate = (case updatastate when 0 then 2 else updatastate end) ";
        String sql5 = "update tb_user_detail_list_type set uid = " + uid + " ,updatestate = (case updatestate when 0 then 2 else updatestate end) ";
        String sql6 = "update ScheduleTable set schUpdateState = 1";
        String sql7 = "update CLRepeatTable set repUpdateState = 1";
        String sql8 = "update tb_user_detail_ly set uid = " + uid;
        String sql9 = "update FrendLyTable set uid = " + uid;//任务留言
        String sql10 = "update FriendsListTable set uid = " + uid;//任务联系人
        String sql11 = "update FriendsTable set uId = " + uid;//老好友
        String sql12 = "update NewTagTable set uid = " + uid;//老好友
        String sql13 = "update tb_user_detail_list_title set uid = " + uid;
        String sql14 = "update tb_user_detail_list_class1 set uid = " + uid;
        String sql16 = "update tb_calendar_list_class1 set uid = " + uid;
        String sql17 = "update tb_timepreinstall_list_class1 set uid = " + uid;
        String sql18 = "update tb_timepreinstall_list_class1 set uid = " + uid + " ,updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId != '0111' and titleId != '1111' and titleId != '2111'";

        try {
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql4);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql5);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql6);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql7);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql8);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql9);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql10);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql11);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql12);
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            sqldb.execSQL(sql13);
            sqldb.execSQL(sql14);
            sqldb.execSQL(sql15);
            sqldb.execSQL(sql16);
            sqldb.execSQL(sql17);
            sqldb.execSQL(sql18);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 获取当期用户当前标题  id的updatestate
     *
     * @param titleId
     * @param uid
     * @return
     */
    public int getNoteTitleState(String titleId, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select updatestate from tb_user_detail_list_title where titleId = '" + titleId + "' and uid = " + uid;
        int updatestate = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatestate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return updatestate;
    }

    /**
     * 获取当期用户当前标题id的详情id的updatestate
     *
     * @param titleid
     * @param uid
     * @return
     */
    public int getNoteTitleDetailState(String titleid, String uid, int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select updatestate from tb_user_detail_list_class1  where titleId = '" + titleid + "' and uid = '" + uid + "' and id = " + id;
        int updatestate = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatestate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return updatestate;
    }

    /**
     * 获取当期用户当前清单日程的详情id的updatestate
     *
     * @param titleid
     * @param uid
     * @return
     */
    public int getCalenderNoteDetailState(String titleid, String uid, int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select updatestate from tb_calendar_list_class1  where titleId = '" + titleid + "' and uid = '" + uid + "' and id = " + id;
        int updatestate = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatestate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return updatestate;
    }

    /**
     * 修改清单标题ID
     *
     * @param id
     * @param newid
     * @param userid
     */
    public void updateNoteTitleId(int id, int newid, String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set id = " + newid
                + " where id = " + id + " and uid = '" + userid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void updateSendRepeatNoteTitleId(int id, int newid, String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task set id = " + newid
                + " where id = " + id + " and uId = '" + userid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改本地联系人ID
     *
     * @param id
     * @param newid
     * @param userid
     */
    public void updateNewFriendId(int id, int newid, String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update NewFriendTable set id = " + newid
                + " where id = " + id + " and uid = '" + userid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改清单详情ID
     *
     * @param id
     * @param newid
     * @param userid
     */
    public void updateNoteDetailId(int id, int newid, String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 set id = " + newid
                + " where id = " + id + " and uid = '" + userid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public void updateSendRepeatNoteDetailId(String id, int newid, String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 set id = " + newid
                + " where id = " + id + " and uId = " + userid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改清单日程详情ID
     *
     * @param id
     * @param newid
     * @param userid
     */
    public void updateCalenderNoteDetailId(int id, int newid, String userid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_calendar_list_class1 set id = " + newid
                + " where id = " + id + " and uid = '" + userid + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 删除清单标题
     */
    public void deleteNoteTitleData(int id, String uid, boolean isNewAddNote) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        String sql1 = "";
        if (isNewAddNote) {
            sql = "delete from tb_user_detail_list_title where id = " + id + " and uid = " + uid;
        } else {
            sql = "update tb_user_detail_list_title set updatestate = 3, other1 = '0' where id = " + id + " and uid = " + uid;
        }

        try {
            sqldb.execSQL(sql);
            if (!isNewAddNote) {
                sqldb.execSQL(sql1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 清单日程删除子项
     *
     * @param titleId
     * @param uid
     * @param isNewAddNote
     */
    public void deleteCalenderNoteData(String titleId, String uid, boolean isNewAddNote) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        String sql1 = "";
        if (isNewAddNote) {
            sql = "delete from tb_calendar_list_class1 where titleId = '" + titleId + "' and uid = " + uid;
        } else {
            sql = "update tb_calendar_list_class1 set updatestate = 3 where titleId = '" + titleId + "' and uid = " + uid;
        }

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSendRepeatNoteData(int id) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_frends_task set updatestate = 3 where id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSendRepeatNoteData1(int id) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from tb_user_frends_task where id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteNoteTitleData(String titleId, String uid, boolean isNewAddNote) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        String sql1 = "";
        if (isNewAddNote) {
            sql = "delete from tb_user_detail_list_title where titleId = '" + titleId + "' and uid = " + uid;
        } else {
            sql = "update tb_user_detail_list_title set updatestate = 3, other1 = '0' where titleId = '" + titleId + "' and uid = " + uid;
            sql1 = "update tb_user_detail_list_class1 set updatestate = 3 where titleId = '" + titleId + "' and uid = " + uid;
        }

        try {
            sqldb.execSQL(sql);
            if (!isNewAddNote) {
                sqldb.execSQL(sql1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除清单日程详情
     *
     * @param id
     */
    public void deleteCalenderNoteTitledetailData(int id, String uid, boolean isNewAddNote) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAddNote) {
            sql = "delete from tb_calendar_list_class1 where id = " + id + " and uid = " + uid;
        } else {
            sql = "update tb_calendar_list_class1 set updatestate = 3  where id = " + id + " and uid = " + uid;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除清单详情
     *
     * @param id
     */
    public void deleteNoteTitledetailData(int id, String uid, boolean isNewAddNote) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAddNote) {
            sql = "delete from tb_user_detail_list_class1 where id = " + id + " and uid = " + uid;
        } else {
            sql = "update tb_user_detail_list_class1 set updatestate = 3  where id = " + id + " and uid = " + uid;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除本地联系人
     *
     * @param id
     */
    public void deleteNewFriendData(int id, String uid, boolean isNewAdd) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAdd) {
            sql = "delete from NewFriendTable where id = " + id + " and uid = " + uid;
        } else {
            sql = "update NewFriendTable set updatastate = 3  where id = " + id + " and uid = " + uid;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取同步中失败id的titleid
     *
     * @param uid
     * @param id
     * @return
     */
    public String getAllErrorNoteTitleId(String uid, int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select titleId from tb_user_detail_list_title where uid = '" + uid + "' and id = " + id;
        String list = "";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                list = cursor.getString(cursor.getColumnIndex("titleId"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }

    /**
     * 获取同步失败的清单titleid下的详情id
     *
     * @param titleId
     * @return
     */
    public int getErrorNoteDetailId(String titleId, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_user_detail_list_class1 where titleId = '" + titleId + "' and uid = '" + uid + "'";
        int list = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                list = cursor.getInt(cursor.getColumnIndex("id"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }

    /**
     * 获取同步失败的清单日程titleid下的详情id
     *
     * @param titleId
     * @return
     */
    public int getErrorCalenderNoteDetailId(String titleId, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_calendar_list_class1 where titleId = '" + titleId + "' and uid = '" + uid + "'";
        int list = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                list = cursor.getInt(cursor.getColumnIndex("id"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }

    /**
     * 删除清单标题,判断是否是新建清单
     *
     * @param titleId
     * @param uid
     * @param isNewAddNote
     */
    public void deleteNoteTitle(String titleId, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "";
        if (isNewAddNote) {
            sql = "delete from tb_user_detail_list_title where titleId = '" + titleId + "' and uid = " + uid;
        } else {
            sql = "update tb_user_detail_list_title set updatestate = 3 where titleId = '" + titleId + "' and uid = " + uid;
        }
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题的nums
     *
     * @param titleid
     * @param uid
     * @param nums
     */
    public void updateNoteTitleNums(String titleid, String uid, String nums) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set updatestate = (case updatestate when 0 then 2 else updatestate end),nums= '" + nums + "' where titleId = '" + titleid + "' and uid = " + uid;
        String sql1 = "update tb_user_detail_list_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end),nums= '" + nums + "' where titleId = '" + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程详情的nums
     *
     * @param titleid
     * @param uid
     * @param nums
     */
    public void updateCalenderNoteNums(String titleid, String uid, String nums) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql1 = "update tb_calendar_list_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end),nums= '" + nums + "' where titleId = '" + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除清单日程详情项,判断是否是新建清单
     *
     * @param id
     * @param titleId
     * @param uid
     * @param isNewAddNote
     */
    public void deleteCalenderNoteDetail(int id, String titleId, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAddNote) {
            sql = "delete from tb_calendar_list_class1 where titleId = '" + titleId + "' and uid = " + uid + " and id = " + id;
        } else {
            sql = "update tb_calendar_list_class1 set updatestate = 3 where titleId = '" + titleId + "' and uid = " + uid + " and id = " + id;
        }

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSendRepeatNoteDetail(int id, String titleId, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAddNote) {
            sql = "delete from tb_user_frends_task_class1 where titleId = '" + titleId + "' and uId = " + uid + " and id = " + id;
        } else {
            sql = "update tb_user_frends_task_class1 set updatestate = 3 where titleId = '" + titleId + "' and uId = " + uid + " and id = " + id;
        }

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSendRepeatNoteDetails(String id, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from tb_user_frends_task_class1 where uId = " + uid + " and id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除清单详情项,判断是否是新建清单
     *
     * @param id
     * @param titleId
     * @param uid
     * @param isNewAddNote
     */
    public void deleteNoteDetail(int id, String titleId, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAddNote) {
            sql = "delete from tb_user_detail_list_class1 where titleId = '" + titleId + "' and uid = " + uid + " and id = " + id;
        } else {
            sql = "update tb_user_detail_list_class1 set updatestate = 3 where titleId = '" + titleId + "' and uid = " + uid + " and id = " + id;
        }
        String sql1 = "update tb_user_detail_list_title set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void deleteSendRepeatNoteDetail2(int id, String titleId, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql;
        if (isNewAddNote) {
            sql = "delete from tb_user_frends_task_class1 where titleId = '" + titleId + "' and uId = " + uid + " and id = " + id;
        } else {
            sql = "update tb_user_frends_task_class1 set updatestate = 3 where titleId = '" + titleId + "' and uId = " + uid + " and id = " + id;
        }
        String sql1 = "update tb_user_frends_task set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uId = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题内容
     *
     * @param titleId
     * @param uid
     * @param titleStr
     */
    public void updateNoteTitle(String titleId, String uid, String titleStr, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set changeTime = '" + DateUtil.nowTime() + "', titles = '" + titleStr + "'" + (isNewAddNote ? ", updatestate = 1 "
                : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = '" + uid + "'";
        String sql2 = "update tb_user_detail_list_class1 set changeTime = '" + DateUtil.nowTime() + "', titles = '" + titleStr + "'" + (isNewAddNote ? ", updatestate = 1 "
                : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = '" + uid + "'";
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程标题内容
     *
     * @param titleId
     * @param uid
     * @param titleStr
     */
    public void updateCalenderNoteTitle(String titleId, String uid, String titleStr, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql2 = "update tb_calendar_list_class1 set changeTime = '" + DateUtil.nowTime() + "', titles = '" + titleStr + "'" + (isNewAddNote ? ", updatestate = 1 "
                : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = '" + uid + "'";
        try {
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteTitle(String titleId, String uid, String titleStr, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql2 = "update tb_user_frends_task_class1 set changeTime = '" + DateUtil.nowTime() + "', titles = '" + titleStr + "'" + (isNewAddNote ? ", updatestate = 1 "
                : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uId = '" + uid + "'";
        try {
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 是否显示有标题
     *
     * @param titleId
     * @param uid
     */
    public void updateNoteIsTitle(String titleId, String uid, String remark) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set changeTime = '" + DateUtil.nowTime() + "', remark = '" + remark + "',updatestate = (case updatestate when 0 then 2 else updatestate end)  where titleId = '" + titleId + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单详情项内容
     *
     * @param id
     * @param titleId
     * @param uid
     * @param DetailStr
     */
    public void updateNoteDetail(int id, String titleId, String uid, String DetailStr, String changetime, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_class1 set changeTime = '" + changetime + "', contents = '" + DetailStr + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = '" + uid + "' and id = " + id;

        String sql1 = "update tb_user_detail_list_title set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程详情项内容
     *
     * @param id
     * @param titleId
     * @param uid
     * @param DetailStr
     */
    public void updateCalenderNoteDetail(int id, String titleId, String uid, String DetailStr, String changetime, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_calendar_list_class1 set changeTime = '" + changetime + "', contents = '" + DetailStr + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = '" + uid + "' and id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetail(int id, String titleId, String uid, String DetailStr, String changetime, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_frends_task_class1 set changeTime = '" + changetime + "', contents = '" + DetailStr + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uId = '" + uid + "' and id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题图片,删除图片titleImageName = ""
     *
     * @param titleId
     * @param uid
     * @param titleImageName
     */
    public void updateNoteTitleImage(String titleId, String uid, String titleImageName, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_title set changeTime = '" + DateUtil.nowTime() + "', imgPath = '" + titleImageName + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;
        String sql2 = "update tb_user_detail_list_class1 set changeTime = '" + DateUtil.nowTime() + "', imgPath = '" + titleImageName + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteTitleImage(String titleId, String uid, String titleImageName, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_frends_task set changeTime = '" + DateUtil.nowTime() + "', remark = '" + titleImageName + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uId = " + uid;
        String sql2 = "update tb_user_frends_task_class1 set changeTime = '" + DateUtil.nowTime() + "', imgPath = '" + titleImageName + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uId = " + uid;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程标题图片,删除图片titleImageName = ""
     *
     * @param titleId
     * @param uid
     * @param titleImageName
     */
    public void updateCalenderNoteTitleImage(String titleId, String uid, String titleImageName, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql2 = "update tb_calendar_list_class1 set changeTime = '" + DateUtil.nowTime() + "', imgPath = '" + titleImageName + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单详情图片,删除图片titleImageName = ""
     *
     * @param id
     * @param titleId
     * @param uid
     * @param titleImageName
     */
    public void updateNoteDetailImage(String id, String titleId, String uid, String titleImageName, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_list_class1 set changeTime = '" + DateUtil.nowTime() + "', imgPath = '" + titleImageName + "'" + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = '" + uid + "' and id = '" + id + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取本地联系人最小id
     *
     * @return
     */
    public int getNFMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from NewFriendTable order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    /**
     * 获取清单日程详情最小id
     *
     * @return
     */
    public int getCalenderMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_calendar_list_class1 order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    public int getSendRepeatNoteMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_user_frends_task order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    public int getSendRepeatNoteChildMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_user_frends_task_class1 order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    /**
     * 获取清单最小id
     *
     * @return
     */
    public int getScheduleTableMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select schID from ScheduleTable order by schID asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("schID"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    public int gettb_calendar_list_class1MinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_calendar_list_class1 order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    public int getMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_user_detail_list_class1 order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    /**
     * 获取清单最小id
     *
     * @return
     */
    public int getTiMinId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select id from tb_user_detail_list_title order by id asc limit 1";
        int id = -1;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                id = cursor.getInt(cursor.getColumnIndex("id"));
            }

            if (id > 0) {
                id = -1;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return id;
    }

    /**
     * 设置清单展示样式 0 勾选 1原点 2数字序列
     *
     * @param titleId
     * @param style
     */
    public void setNoteStyle(String titleId, String uid, int style, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set styles = " + style + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;
        String sql2 = "update tb_user_detail_list_class1 set style = " + style + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 设置清单日程展示样式 0 勾选 1原点 2数字序列
     *
     * @param titleId
     * @param style
     */
    public void setCalenderNoteStyle(String titleId, String uid, int style, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql2 = "update tb_calendar_list_class1 set style = " + style + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void setSendRepeatNoteStyle(String titleId, String uid, int style, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql2 = "update tb_user_frends_task_class1 set style = " + style + (isNewAddNote ? ", updatestate = 1 " : ", updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleId + "' and uId = " + uid;
        try {
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单详情排序id
     *
     * @param orderId
     * @param id
     * @param titleid
     * @param uid
     */
    public void updateNoteDetailOrderId(int orderId, int id, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 " + (isNewAddNote ? " set updatestate = 1 " : " set updatestate = (case updatestate when 0 then 2 else updatestate end) ") + ", orderId = " + orderId + " where id = " + id + " and titleId = '" + titleid + "' and uid = " + uid;
        String sql1 = "update tb_user_detail_list_title " + (isNewAddNote ? " set updatestate = 1 " : " set updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleid + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatnoteDetailOrderId(int orderId, int id, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 " + (isNewAddNote ? " set updatestate = 1 " : " set updatestate = (case updatestate when 0 then 2 else updatestate end) ") + ", orderId = " + orderId + " where id = " + id + " and titleId = '" + titleid + "' and uId = " + uid;
        String sql1 = "update tb_user_frends_task " + (isNewAddNote ? " set updatestate = 1 " : " set updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleid + "' and uId = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程详情排序id
     *
     * @param orderId
     * @param id
     * @param titleid
     * @param uid
     */
    public void updateCalenderNoteDetailOrderId(int orderId, int id, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_calendar_list_class1 " + (isNewAddNote ? " set updatestate = 1 " : " set updatestate = (case updatestate when 0 then 2 else updatestate end) ") + ", orderId = " + orderId + " where id = " + id + " and titleId = '" + titleid + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetailOrderId(int orderId, int id, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 " + (isNewAddNote ? " set updatestate = 1 " : " set updatestate = (case updatestate when 0 then 2 else updatestate end) ") + ", orderId = " + orderId + " where id = " + id + " and titleId = '" + titleid + "' and uId = " + uid;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单详情状态值,全部
     *
     * @param titleid
     * @param uid
     */
    public void updateNoteDetailOrderId(String titleid, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end)  where titleId = '" + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单日程详情状态值,全部
     *
     * @param titleid
     * @param uid
     */
    public void updateCalenderNoteDetailOrderId(String titleid, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_calendar_list_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end)  where titleId = '" + titleid + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetailOrderId(String titleid, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end)  where titleId = '" + titleid + "' and uId = " + uid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 同时修改内容的排序
     *
     * @param titleid
     * @param uid
     * @param id
     * @param orderid
     */
    public void updateNoteContentAndOrder(String titleid, String uid, int id, int orderid, String contents) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 set updatestate = (case updatestate when 0 then 2 else updatestate end),set orderId = " +
                orderid + ",contents = '" + contents + "'  where titleId = '" +
                titleid + "' and uid = " +
                uid + " and id = " + id;

        String sql1 = "update tb_user_detail_list_title set updatestate = (case updatestate when 0 then 2 else updatestate end) where titleId = '" + titleid + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 清单详情结束
     *
     * @param id
     * @param endstate
     * @param titleid
     * @param uid
     * @param isNewAddNote
     */
    public void updateNoteDetailEndstate(int id, int endstate, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_class1 set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " , endstate = " + endstate + " where id = " + id + " and titleId = '" + titleid + "' and uid = " + uid;
        String sql1 = "update tb_user_detail_list_title set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " where titleId = '" + titleid + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 清单日程详情结束
     *
     * @param id
     * @param endstate
     * @param titleid
     * @param uid
     * @param isNewAddNote
     */
    public void updateCalenderNoteDetailEndstate(int id, int endstate, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_calendar_list_class1 set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " , endstate = " + endstate + " where id = " + id + " and titleId = '" + titleid + "' and uid = " + uid;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateSendRepeatNoteDetailEndstate(int id, int endstate, String titleid, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_frends_task_class1 set " + (isNewAddNote ? " updatestate = 1 " : " updatestate = (case updatestate when 0 then 2 else updatestate end) ") + " , endstate = " + endstate + " where id = " + id + " and titleId = '" + titleid + "' and uId = " + uid;

        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 修改清单标题图片和粘贴位置
     *
     * @param appicon
     * @param copystyle
     * @param titleId
     * @param uid
     */
    public void updateNoteTitleIconCopy(int appicon, String copystyle, String titleId, String uid, boolean isNewAddNote) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update tb_user_detail_list_title set " + (isNewAddNote ? " updatestate = 1, " : "updatestate = (case updatestate when 0 then 2 else updatestate end) ,") + " ltype = " + appicon + " , copys = '" + copystyle + "' where titleId = '" + titleId + "' and uid = " + uid;
        String sql2 = "update tb_user_detail_list_class1 set " + (isNewAddNote ? " updatestate = 1, " : "updatestate = (case updatestate when 0 then 2 else updatestate end) , ") + " ltype = " + appicon + " where titleId = '" + titleId + "' and uid = " + uid;
        try {
            sqldb.execSQL(sql);
            sqldb.execSQL(sql2);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 返回titleid state
     *
     * @param titleid
     * @return
     */
    public boolean getNoteTitleUpdateState(String titleid, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from tb_user_detail_list_title where titleId = '" + titleid + "' and updatestate != 0 and updatestate != -1 and uid = " + uid;
        boolean invUpdateState = true;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invUpdateState = false;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invUpdateState;
    }

    /**
     * 当前titleid下详情的state
     *
     * @param titleid
     * @param uid
     * @return
     */
    public boolean getNoteTitleDetailUpdateState(String titleid, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from tb_user_detail_list_class1 where titleId = '" + titleid + "' and updatestate != 0 and updatestate != -1 and uid = " + uid;
        boolean invUpdateState = true;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invUpdateState = false;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invUpdateState;
    }

    /**
     * 当前清单日程titleid下详情的state
     *
     * @param titleid
     * @param uid
     * @return
     */
    public boolean getCalenderNoteTitleDetailUpdateState(String titleid, String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from tb_calendar_list_class1 where titleId = '" + titleid + "' and updatestate != 0 and updatestate != -1 and uid = " + uid;
        boolean invUpdateState = true;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invUpdateState = false;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invUpdateState;
    }

    /**
     * 判断是否有备忘录
     *
     * @return
     */
    public boolean getNoteTitleBWL(String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from tb_user_detail_list_title where uid = " + uid;
        boolean isBwl = false;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                isBwl = true;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return isBwl;
    }


    /**
     * 修改清单标题是否公开 0 私密  1 公开
     *
     * @param uid
     * @param titleid
     * @param openState
     */
    public void updateNoteTitleOpenState(String uid, String titleid, int openState) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from tb_user_detail_list_title where uid = " + uid + " and titleId = '" + titleid + "'";
        int updatestate = 1;
        try {
            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                updatestate = cursor.getInt(cursor.getColumnIndex("updatestate"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        String sql1 = "update tb_user_detail_list_title set " + (updatestate == 1 ? " updatestate = 1, " : "updatestate = (case updatestate when 0 then 2 else updatestate end) , ") + " openState = " + openState + " where uid = " + uid + " and titleId = '" + titleid + "'";
        try {
            sqldb.execSQL(sql1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 判断是否有购物清单
     *
     * @return
     */
    public boolean getNoteTitleBuyNote(String uid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from tb_user_detail_list_title where uid = " + uid + " and titleId = '1'";
        boolean isBwl = false;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                isBwl = true;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return isBwl;
    }


    /**
     * 获取清单ID下打钩的数量
     *
     * @param
     * @return
     */
    public int getNoteDetailEndstateNums(String titleId, String userid) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        int invTick = 0;

        String sql = "select * from tb_user_detail_list_class1 where titleId = '" + titleId + "' and endstate = 1 and uid = " + userid;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTick++;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return invTick;
    }

    /**
     * 获取清单日程ID下打钩的数量
     *
     * @param
     * @return
     */
    public int getCaalenderNoteDetailEndstateNums(String titleId, String userid) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        int invTick = 0;

        String sql = "select * from tb_calendar_list_class1 where titleId = '" + titleId + "' and endstate = 1 and uid = " + userid;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTick++;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return invTick;
    }

    public int getNoteDetailEndstateNums(String titleId, String userid, int endstate) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        int invTick = 0;

        String sql = "select * from tb_user_detail_list_class1 where titleId = '" + titleId + "' and endstate = " + endstate + " and uid = " + userid;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTick++;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return invTick;
    }

    public int getCalednerNoteDetailEndstateNums(String titleId, String userid, int endstate) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        int invTick = 0;

        String sql = "select * from tb_calendar_list_class1 where titleId = '" + titleId + "' and endstate = " + endstate + " and uid = " + userid;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTick++;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return invTick;
    }

    /**
     * 存储清单数据
     *
     * @param clInventoryListBean
     */
    public void SaveQdData(CLInventoryListBean clInventoryListBean) {
        SQLiteDatabase sqLiteDatabase = helper.getWritableDatabase();

        String sql = "replace into CLInventoryModelTable(invID,invUID,invTitleID,invTick,invOrderIndex," +
                "invType,invStyle,invPasteStyle,invContent,invTitle,invUpdateTime,invCreateTime,invImagePath," +
                "invImageURL,invTitleImage,invWebURL,invRemark,invRemark1,invRemark2) " +
                "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

        Object[] value = new Object[]{
                clInventoryListBean.id,
                clInventoryListBean.uid,
                StringUtils.getIsStringEqulesNull(clInventoryListBean.titleId),
                clInventoryListBean.endstate,
                clInventoryListBean.orderId,
                clInventoryListBean.lType,
                clInventoryListBean.style,
                StringUtils.getIsStringEqulesNull(clInventoryListBean.remark),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.contents),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.titles),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.changetime),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.createTime.replace('T', ' ')),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.cpath),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.curl),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.imgPath),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.imgUrl),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.nums),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.shareUrl),
                StringUtils.getIsStringEqulesNull(clInventoryListBean.remark1),};

        try {
//            Log.e("TAG",sql+"----"+value.toString());
            sqLiteDatabase.execSQL(sql, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 获取清单数据
     *
     * @param uid
     * @return
     */
    public ArrayList<CLInventoryListBean> getAllQdData(String uid, boolean tb) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<CLInventoryListBean> listBeanArrayList = new ArrayList<>();

//        String sql = "select * from CLInventoryModelTable where invUID ="+uid+" order by invUpdateTime desc";
        //获取清单中invTitleID,更新信息最大项
        String sql = "";
        if (tb) {
            sql = "select * from CLInventoryModelTable where invUID = " + uid + " and invUpdateState != 0 and invUpdateState != -1";
        } else {
            sql = "select * from CLInventoryModelTable where invUID = " + uid + " and invUpdateState != 3 group by invTitleID order by invTitleID";// ,invCreateTime desc
        }
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                //(invID,invUID,invTitleID,invTick,invOrderIndex,invUpdateState," +
//                "invType,invStyle,invPasteStyle,invContent,invTitle,invUpdateTime,invCreateTime,invImagePath," +
//                        "invImageURL,invTitleImage,invWebURL,invRemark,invRemark1,invRemark2)
                CLInventoryListBean clInventoryListBean = new CLInventoryListBean();
                clInventoryListBean.id = cursor.getInt(cursor.getColumnIndex("invID"));
                clInventoryListBean.uid = cursor.getInt(cursor.getColumnIndex("invUID"));
                clInventoryListBean.titleId = cursor.getString(cursor.getColumnIndex("invTitleID"));
                clInventoryListBean.endstate = cursor.getInt(cursor.getColumnIndex("invTick"));
                clInventoryListBean.orderId = cursor.getInt(cursor.getColumnIndex("invOrderIndex"));
                clInventoryListBean.lType = cursor.getInt(cursor.getColumnIndex("invType"));
                clInventoryListBean.style = cursor.getInt(cursor.getColumnIndex("invStyle"));
                clInventoryListBean.remark = cursor.getString(cursor.getColumnIndex("invPasteStyle"));
                clInventoryListBean.contents = cursor.getString(cursor.getColumnIndex("invContent"));
                clInventoryListBean.titles = cursor.getString(cursor.getColumnIndex("invTitle"));
                clInventoryListBean.changetime = cursor.getString(cursor.getColumnIndex("invUpdateTime"));
                clInventoryListBean.createTime = cursor.getString(cursor.getColumnIndex("invCreateTime"));
                clInventoryListBean.cpath = cursor.getString(cursor.getColumnIndex("invImagePath"));
                clInventoryListBean.curl = cursor.getString(cursor.getColumnIndex("invImageURL"));
                clInventoryListBean.imgPath = cursor.getString(cursor.getColumnIndex("invTitleImage"));
                clInventoryListBean.imgUrl = cursor.getString(cursor.getColumnIndex("invWebURL"));
                clInventoryListBean.nums = cursor.getString(cursor.getColumnIndex("invRemark"));
                clInventoryListBean.shareUrl = cursor.getString(cursor.getColumnIndex("invRemark1"));
                clInventoryListBean.remark1 = cursor.getString(cursor.getColumnIndex("invRemark2"));
                listBeanArrayList.add(clInventoryListBean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listBeanArrayList;
    }


    /**
     * 获取清单ID下的清单
     *
     * @param invTitleID
     * @return
     */
    public ArrayList<CLInventoryListBean> getTitleIdQdData(String invTitleID) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<CLInventoryListBean> listBeanArrayList = new ArrayList<>();

        String sql = "select * from CLInventoryModelTable where invTitleID = '" + invTitleID + "' and invUpdateState != 3 order by invOrderIndex";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                //(invID,invUID,invTitleID,invTick,invOrderIndex,invUpdateState," +
//                "invType,invStyle,invPasteStyle,invContent,invTitle,invUpdateTime,invCreateTime,invImagePath," +
//                        "invImageURL,invTitleImage,invWebURL,invRemark,invRemark1,invRemark2)
                CLInventoryListBean clInventoryListBean = new CLInventoryListBean();
                clInventoryListBean.id = cursor.getInt(cursor.getColumnIndex("invID"));
                clInventoryListBean.uid = cursor.getInt(cursor.getColumnIndex("invUID"));
                clInventoryListBean.titleId = cursor.getString(cursor.getColumnIndex("invTitleID"));
                clInventoryListBean.endstate = cursor.getInt(cursor.getColumnIndex("invTick"));
                clInventoryListBean.orderId = cursor.getInt(cursor.getColumnIndex("invOrderIndex"));
                clInventoryListBean.lType = cursor.getInt(cursor.getColumnIndex("invType"));
                clInventoryListBean.style = cursor.getInt(cursor.getColumnIndex("invStyle"));
                clInventoryListBean.remark = cursor.getString(cursor.getColumnIndex("invPasteStyle"));
                clInventoryListBean.contents = cursor.getString(cursor.getColumnIndex("invContent"));
                clInventoryListBean.titles = cursor.getString(cursor.getColumnIndex("invTitle"));
                clInventoryListBean.changetime = cursor.getString(cursor.getColumnIndex("invUpdateTime"));
                clInventoryListBean.createTime = cursor.getString(cursor.getColumnIndex("invCreateTime"));
                clInventoryListBean.cpath = cursor.getString(cursor.getColumnIndex("invImagePath"));
                clInventoryListBean.curl = cursor.getString(cursor.getColumnIndex("invImageURL"));
                clInventoryListBean.imgPath = cursor.getString(cursor.getColumnIndex("invTitleImage"));
                clInventoryListBean.imgUrl = cursor.getString(cursor.getColumnIndex("invWebURL"));
                clInventoryListBean.nums = cursor.getString(cursor.getColumnIndex("invRemark"));
                clInventoryListBean.shareUrl = cursor.getString(cursor.getColumnIndex("invRemark1"));
                clInventoryListBean.remark1 = cursor.getString(cursor.getColumnIndex("invRemark2"));
                listBeanArrayList.add(clInventoryListBean);
            }

            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listBeanArrayList;
    }


    /**
     * 同步清单ID下的清单
     *
     * @param invTitleID
     * @return
     */
    public ArrayList<CLInventoryListBean> getTitleIdQdDatas(String invTitleID) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        ArrayList<CLInventoryListBean> listBeanArrayList = new ArrayList<>();

        String sql = "select * from CLInventoryModelTable where invTitleID = '" + invTitleID + "' and invUpdateState != 0 and invUpdateState != -1";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                //(invID,invUID,invTitleID,invTick,invOrderIndex,invUpdateState," +
//                "invType,invStyle,invPasteStyle,invContent,invTitle,invUpdateTime,invCreateTime,invImagePath," +
//                        "invImageURL,invTitleImage,invWebURL,invRemark,invRemark1,invRemark2)
                CLInventoryListBean clInventoryListBean = new CLInventoryListBean();
                clInventoryListBean.id = cursor.getInt(cursor.getColumnIndex("invID"));
                clInventoryListBean.uid = cursor.getInt(cursor.getColumnIndex("invUID"));
                clInventoryListBean.titleId = cursor.getString(cursor.getColumnIndex("invTitleID"));
                clInventoryListBean.endstate = cursor.getInt(cursor.getColumnIndex("invTick"));
                clInventoryListBean.orderId = cursor.getInt(cursor.getColumnIndex("invOrderIndex"));
                clInventoryListBean.lType = cursor.getInt(cursor.getColumnIndex("invType"));
                clInventoryListBean.style = cursor.getInt(cursor.getColumnIndex("invStyle"));
                clInventoryListBean.remark = cursor.getString(cursor.getColumnIndex("invPasteStyle"));
                clInventoryListBean.contents = cursor.getString(cursor.getColumnIndex("invContent"));
                clInventoryListBean.titles = cursor.getString(cursor.getColumnIndex("invTitle"));
                clInventoryListBean.changetime = cursor.getString(cursor.getColumnIndex("invUpdateTime"));
                clInventoryListBean.createTime = cursor.getString(cursor.getColumnIndex("invCreateTime"));
                clInventoryListBean.cpath = cursor.getString(cursor.getColumnIndex("invImagePath"));
                clInventoryListBean.curl = cursor.getString(cursor.getColumnIndex("invImageURL"));
                clInventoryListBean.imgPath = cursor.getString(cursor.getColumnIndex("invTitleImage"));
                clInventoryListBean.imgUrl = cursor.getString(cursor.getColumnIndex("invWebURL"));
                clInventoryListBean.nums = cursor.getString(cursor.getColumnIndex("invRemark"));
                clInventoryListBean.shareUrl = cursor.getString(cursor.getColumnIndex("invRemark1"));
                clInventoryListBean.remark1 = cursor.getString(cursor.getColumnIndex("invRemark2"));
                listBeanArrayList.add(clInventoryListBean);
            }

            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return listBeanArrayList;
    }

    /**
     * 获取清单ID下打钩的数量
     *
     * @param invTitleID
     * @return
     */
    public int geinvTickQdDataNums(String invTitleID) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        int invTick = 0;

        String sql = "select * from CLInventoryModelTable where invTitleID = '" + invTitleID + "' and invTick = 1";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTick++;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return invTick;
    }


    /**
     * 删除子清单
     *
     * @param invID
     */
    public void deleteChildQdData(int invID) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from CLInventoryModelTable where invID = " + invID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 删除父清单
     *
     * @param invTitleID
     */
    public void deleteQdData(String invTitleID) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "delete from CLInventoryModelTable where invUID = '" + invTitleID + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 获取清单中最大的titileiD
     */
    public String minTitleId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

//        String sql = "select max(invTitleID) from CLInventoryModelTable";
        String sql = "select invTitleID from CLInventoryModelTable order by invTitleID";
        String invTitleID = "0";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTitleID = cursor.getString(cursor.getColumnIndex("invTitleID"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invTitleID;
    }

    /**
     * 获取清单最大id
     *
     * @return
     */
    public int minVId() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

//        String sql = "select max(invTitleID) from CLInventoryModelTable";
        String sql = "select invID from CLInventoryModelTable order by invID";
        int invID = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invID = cursor.getInt(cursor.getColumnIndex("invID"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invID;
    }

    public void updateState(int vid, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invUpdateState = " + state + " where invID =" + vid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 修改titleid下的状态
     *
     * @param invTitleID
     * @param state
     */
    public void updateTitleState(String invTitleID, int state) {
        //实例化数据库
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invUpdateState = " + state + " where invTitleID = '" + invTitleID + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取id清单的状态
     *
     * @param invID
     * @return
     */
    public int getIdState(int invID) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

//        String sql = "select max(invTitleID) from CLInventoryModelTable";
        String sql = "select invUpdateState from CLInventoryModelTable where invID = " + invID;
        int invTitle = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invTitle = cursor.getInt(cursor.getColumnIndex("invUpdateState"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invTitle;
    }


    /**
     * 修改titleid的标题
     *
     * @param titleId
     * @param title
     */
    public void setTitle(String titleId, String title) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invTitle = '" + title + "' where invTitleID = '" + titleId + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 设置内容
     *
     * @param id
     * @param content
     */
    public void setContent(int id, String content, String changetime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invContent = '" + content + "',invUpdateTime = '" + changetime + "' where invID =" + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 判断是否有备忘录
     *
     * @return
     */
    public boolean getBwl() {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

//        String sql = "select max(invTitleID) from CLInventoryModelTable";
        String sql = "select * from CLInventoryModelTable";
        boolean isBwl = false;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                isBwl = true;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return isBwl;
    }


    /**
     * 修改图片和粘贴位置
     */
    public void setIconCopy(int appicon, String copystyle, int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invType = " + appicon + " , invPasteStyle = " + copystyle + " where invID =" + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 清单是否打钩
     *
     * @param vid
     * @param tick
     */
    public void checkboxList(int vid, int tick) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invTick = " + tick + " where invID = " + vid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 设置清单展示样式 0 勾选 1原点 2数字序列
     *
     * @param titleId
     * @param style
     */
    public void setListStyle(String titleId, int style) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invStyle = " + style + " where invTitleID = '" + titleId + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 返回该titileid的清单的状态值
     *
     * @param titleId
     * @return
     */
    public List<Integer> getTitleUpdateState(String titleId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from CLInventoryModelTable where invTitleID = '" + titleId + "' and invUpdateState != 0";
        List<Integer> list = new ArrayList<>();
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                int updatestate = cursor.getInt(cursor.getColumnIndex("invUpdateState"));
                list.add(updatestate);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }

    /**
     * 修改清单ID
     *
     * @param invID 老id
     * @param newid 新id
     */
    public void UpdateQdID(int invID, int newid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invID = " + newid
                + " where invID = " + invID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 修改清单ID状态
     *
     * @param invID       老id
     * @param updatestate 状态
     */
    public void UpdateQdUpdateState(int invID, int updatestate) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invUpdateState = " + updatestate
                + " where invID = " + invID;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    /**
     * 修改标题图片
     *
     * @param titleId
     * @param path
     */
    public void updateImageTitle(String titleId, String path) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invTitleImage = '" + path + "' where invTitleID = '" + titleId + "'";
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    /**
     * 返回标题图片
     *
     * @param titleId
     * @return
     */
    public String getTitleOldImagePath(String titleId) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from CLInventoryModelTable where invTitleID = '" + titleId + "'";
        String path = "";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                path = cursor.getString(cursor.getColumnIndex("invTitleImage"));
                if (!path.isEmpty()) {
                    break;
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return path;

    }


    /**
     * 返回titlei
     *
     * @param titleid
     * @return
     */
    public boolean getUpdateState(String titleid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "select * from CLInventoryModelTable where invTitleID = '" + titleid + "' and invUpdateState != 0 and invUpdateState != -1 ";
        boolean invUpdateState = true;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                invUpdateState = false;
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return invUpdateState;
    }

    /**
     * 修改排序id
     *
     * @param index
     * @param vid
     */
    public void updateOrderIdVid(int index, int vid) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();

        String sql = "update CLInventoryModelTable set invOrderIndex = " + index + " where invID = " + vid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    //====================清单留言===================


    /**
     * 保存清单留言数据
     *
     * @param id
     * @param lyUid
     * @param lyName
     * @param lyTitleImg
     * @param cId
     * @param mess
     * @param uid
     * @param titleId
     * @param localTimes
     * @param changeTime
     * @param type
     * @param reamrk
     * @param reamrk1
     * @param reamrk2
     * @return
     */
    public boolean insertNoteLYData(int id, int lyUid, String lyName, String lyTitleImg,
                                    int cId, String mess, int uid, String titleId, String localTimes, String changeTime,
                                    int type, String reamrk, String reamrk1, String reamrk2) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "replace into tb_user_detail_ly(id, lyUid,String,lyName,lyTitleImg,"
                + "cId, mess,uid, titleId,localTimes,"
                + "changeTime, type, reamrk,reamrk1, reamrk2) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{id, lyUid,
                StringUtils.getIsStringEqulesNull(lyName),
                StringUtils.getIsStringEqulesNull(lyTitleImg),
                cId,
                StringUtils.getIsStringEqulesNull(mess),
                uid,
                StringUtils.getIsStringEqulesNull(titleId),
                StringUtils.getIsStringEqulesNull(localTimes),
                StringUtils.getIsStringEqulesNull(changeTime),
                type,
                StringUtils.getIsStringEqulesNull(reamrk),
                StringUtils.getIsStringEqulesNull(reamrk1),
                StringUtils.getIsStringEqulesNull(reamrk2),
        };
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    public void deleteLY(int id) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "delete from tb_user_detail_ly where id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public boolean insertNoteLYData(NoteLYBean.PageBean.ItemsBean bean, String downTime) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "replace into tb_user_detail_ly(id, lyUid,lyName,lyTitleImg,"
                + "cId, mess,uid, titleId,localTimes,"
                + "changeTime, type, reamrk,reamrk1, reamrk2,updatestate,other1) "
                + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        Object[] mValue = new Object[]{bean.id, bean.lyUid,
                StringUtils.getIsStringEqulesNull(bean.lyName),
                StringUtils.getIsStringEqulesNull(bean.lyTitleImg),
                bean.cId,
                StringUtils.getIsStringEqulesNull(bean.mess),
                bean.uid,
                StringUtils.getIsStringEqulesNull(bean.titleId),
                StringUtils.getIsStringEqulesNull(bean.localTimes),
                StringUtils.getIsStringEqulesNull(bean.changeTime).replace("T", " "),
                bean.type,
                StringUtils.getIsStringEqulesNull(bean.reamrk),
                StringUtils.getIsStringEqulesNull(bean.reamrk1),
                StringUtils.getIsStringEqulesNull(bean.reamrk2), 0, downTime,
        };
        try {
            sqldb.execSQL(sql, mValue);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * @param titleId
     * @param id
     * @param isread  1 最新
     */
    public void updateNoteLYDataIsNew(String titleId, int id, int isread) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_ly set other = " + isread + " where titleId = '" + titleId + "' and id = " + id;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void updateAllNoteLYDataIsNew(String titleId, int cid, int isread) {
        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "update tb_user_detail_ly set other = " + isread + " where titleId = '" + titleId + "' and cid = " + cid;
        try {
            sqldb.execSQL(sql);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 获取清单留言
     *
     * @param titleId
     * @param where
     * @return
     */
    public List<NoteLYBean.PageBean.ItemsBean> getAllNoteLYData(String titleId, String where) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_user_detail_ly where titleId = '" + titleId + "' and " + where + " order by replace(tb_user_detail_ly.changeTime,'T',' ') desc";
        List<NoteLYBean.PageBean.ItemsBean> list = new ArrayList<>();
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                NoteLYBean.PageBean.ItemsBean bean = new NoteLYBean.PageBean.ItemsBean();
                bean.id = cursor.getInt(cursor.getColumnIndex("id"));
                bean.mess = cursor.getString(cursor.getColumnIndex("mess"));
                bean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                bean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                bean.lyName = cursor.getString(cursor.getColumnIndex("lyName"));
                bean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                bean.cId = cursor.getInt(cursor.getColumnIndex("cId"));
                bean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                bean.type = cursor.getInt(cursor.getColumnIndex("type"));
                bean.lyTitleImg = cursor.getString(cursor.getColumnIndex("lyTitleImg"));
                bean.lyUid = cursor.getInt(cursor.getColumnIndex("lyUid"));
                bean.reamrk = cursor.getString(cursor.getColumnIndex("reamrk"));
                bean.reamrk2 = cursor.getString(cursor.getColumnIndex("reamrk2"));
                bean.reamrk1 = cursor.getString(cursor.getColumnIndex("reamrk1"));
                list.add(bean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return list;
    }


    /**
     * 获取清单留言
     *
     * @param titleId
     * @param where
     * @return
     */
    public NoteLYBean.PageBean.ItemsBean getOneNoteLYData(String titleId, String where) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_user_detail_ly where titleId = '" + titleId + "' and " + where + " order by  replace(tb_user_detail_ly.changeTime,'T',' ') desc limit 1";
        NoteLYBean.PageBean.ItemsBean bean = null;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                bean = new NoteLYBean.PageBean.ItemsBean();
                bean.id = cursor.getInt(cursor.getColumnIndex("id"));
                bean.mess = cursor.getString(cursor.getColumnIndex("mess"));
                bean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                bean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                bean.lyName = cursor.getString(cursor.getColumnIndex("lyName"));
                bean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                bean.cId = cursor.getInt(cursor.getColumnIndex("cId"));
                bean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                bean.type = cursor.getInt(cursor.getColumnIndex("type"));
                bean.lyTitleImg = cursor.getString(cursor.getColumnIndex("lyTitleImg"));
                bean.lyUid = cursor.getInt(cursor.getColumnIndex("lyUid"));
                bean.reamrk = cursor.getString(cursor.getColumnIndex("reamrk"));
                bean.reamrk2 = cursor.getString(cursor.getColumnIndex("reamrk2"));
                bean.reamrk1 = cursor.getString(cursor.getColumnIndex("reamrk1"));
//                list.add(bean);
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return bean;
    }

    public NoteLYBean.PageBean.ItemsBean getOneNoteLYData(String titleId, int cid) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_user_detail_ly where titleId = '" + titleId + "' and cId = " + cid + " order by replace(tb_user_detail_ly.changeTime,'T',' ') desc limit 1";
        NoteLYBean.PageBean.ItemsBean bean = new NoteLYBean.PageBean.ItemsBean();
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                bean.id = cursor.getInt(cursor.getColumnIndex("id"));
                bean.mess = cursor.getString(cursor.getColumnIndex("mess"));
                bean.changeTime = cursor.getString(cursor.getColumnIndex("changeTime"));
                bean.uid = cursor.getInt(cursor.getColumnIndex("uid"));
                bean.lyName = cursor.getString(cursor.getColumnIndex("lyName"));
                bean.localTimes = cursor.getString(cursor.getColumnIndex("localTimes"));
                bean.cId = cursor.getInt(cursor.getColumnIndex("cId"));
                bean.titleId = cursor.getString(cursor.getColumnIndex("titleId"));
                bean.type = cursor.getInt(cursor.getColumnIndex("type"));
                bean.lyTitleImg = cursor.getString(cursor.getColumnIndex("lyTitleImg"));
                bean.lyUid = cursor.getInt(cursor.getColumnIndex("lyUid"));
                bean.reamrk = cursor.getString(cursor.getColumnIndex("reamrk"));
                bean.reamrk2 = cursor.getString(cursor.getColumnIndex("reamrk2"));
                bean.reamrk1 = cursor.getString(cursor.getColumnIndex("reamrk1"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return bean;
    }

    public int getOneNoteLYDataIsRead(String titleId) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_user_detail_ly where titleId = '" + titleId + "' order by replace(tb_user_detail_ly.changeTime,'T',' ') desc";
        int isRead = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                isRead = cursor.getInt(cursor.getColumnIndex("other"));
                if (isRead == 1) {
                    break;
                }
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return isRead;
    }

    public int getOneNoteLYDataIsRead(String titleId, int cid) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_user_detail_ly where titleId = '" + titleId + "' and cId = " + cid + " order by replace(tb_user_detail_ly.changeTime,'T',' ') desc limit 1";
        int isRead = 0;
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                isRead = cursor.getInt(cursor.getColumnIndex("other"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return isRead;
    }

    public String getCalenderNoteDataDownTime() {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_calendar_list_class1 order by changeTime desc limit 1";
        String downtime = "";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                downtime = cursor.getString(cursor.getColumnIndex("changeTime"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return downtime;
    }

    public String getOneNoteLYDataDownTime(String titleId) {

        SQLiteDatabase sqldb = helper.getWritableDatabase();
        String sql = "select * from tb_user_detail_ly where titleId = '" + titleId + "' order by other1 desc limit 1";
        String downtime = "";
        try {

            Cursor cursor = sqldb.rawQuery(sql, null);
            while (cursor.moveToNext()) {
                downtime = cursor.getString(cursor.getColumnIndex("other1"));
                break;
            }
            cursor.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return downtime;
    }
}
